public void showDialog(
     @EventType int modelEventType, List<ConfigurationItem> selectedConfigurationItems) {
   if (isDialogVisible()
       && isFastModeEnabled()
       && modelEventType == EVENT_TYPE_VIEW_LONG_CLICKED) {
     return;
   } else if (!isDialogVisible()
       && (modelEventType == EVENT_TYPE_VIEW_CLICKED
           || modelEventType == EVENT_TYPE_VIEW_FOCUSED)) {
     return;
   }
   helper.clearConfigurationVariables();
   setSortedConfigurationItems(selectedConfigurationItems);
   if (!isDialogVisible()) {
     setExpandIconVisible(true);
     setDialogVisible(true);
     notifyPropertyChanged(PROPERTY_DIALOG_INITIAL_POSITION);
   }
   notifyPropertyChanged(PROPERTY_DATA_SET);
   notifyPropertyChanged(PROPERTY_DATA_SET_SCROLL_POSITION);
   if (isFastModeEnabled() || modelEventType == EVENT_TYPE_VIEW_LONG_CLICKED) {
     setSelectedConfigItem(sortedConfigurationItems.get(0));
     actionCallbacks.setText(getSelectedConfigItemValue());
     notifyPropertyChanged(PROPERTY_DATA_SET);
   }
 }
 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;
 }
 private String replaceVariableKeysWithValues(String text) {
   String newText = text.replace("\\n", "\n");
   // If entry contains variables then we will replace them with appropriate values
   Pattern pattern = Pattern.compile(configurationVariablePattern);
   Matcher m = pattern.matcher(newText);
   StringBuffer sb = new StringBuffer(newText.length());
   while (m.find() && m.groupCount() > 0) {
     String variableKey = m.group(1);
     String value = helper.getConfigurationVariableValue(variableKey);
     if (value != null) {
       m.appendReplacement(sb, Matcher.quoteReplacement(value));
     }
   }
   m.appendTail(sb);
   return sb.toString();
 }