Program: 149528
Project: 149528
Buggy source:
/** 
 * Load selected standard templates.
 * @param settings the settings
 */
private void loadSelectedStandardTemplates(ConfigurationTemplateSettings.Builder settings){
  final String[] inlineNames=listInlineTemplates();
  final TemplateResource[] templates=listTemplateResources();
  if (templates.length + inlineNames.length == 0)   return;
  MultiDialog md=new MultiDialog("String_Node_Str",new MultiDialog.BaseItems(){
    public int size(){
      return templates.length + inlineNames.length;
    }
    public String getFormattedName(    int i){
      if (i < inlineNames.length)       return inlineNames[i];
      return templates[inlineNames.length + i].name;
    }
  }
);
  md.addSelected(settings.getSelectedStandardTemplatesList());
  md.showDialog();
  if (md.wasCanceled())   return;
  ArrayList<String> selected=md.getSelectedResults();
  if (selected.isEmpty())   return;
  settings.clearSelectedStandardTemplates();
  settings.addAllSelectedStandardTemplates(selected);
  int count=0;
  final HashSet<String> remaining=new HashSet<String>(selected.size());
  for (int i=0; i < selected.size(); i++) {
    String name=selected.get(i);
    Template t=inlineTemplates.get(name);
    if (t != null) {
      count++;
      map.put(name,t);
    }
 else {
      remaining.add(name);
    }
  }
  if (!remaining.isEmpty()) {
    TurboList<TemplateResource> list=new TurboList<TemplateResource>(remaining.size());
    for (    TemplateResource t : templates) {
      if (remaining.contains(t.name))       list.add(t);
    }
    count+=loadTemplateResources(list.toArray(new TemplateResource[list.size()]));
  }
  if (count > 0)   saveDefaultTemplates();
  IJ.showMessage("String_Node_Str" + TextUtils.pleural(count,"String_Node_Str"));
}

Fixed version (ground truth):
/** 
 * Load selected standard templates.
 * @param settings the settings
 */
private void loadSelectedStandardTemplates(ConfigurationTemplateSettings.Builder settings){
  final String[] inlineNames=listInlineTemplates();
  final TemplateResource[] templates=listTemplateResources();
  if (templates.length + inlineNames.length == 0)   return;
  MultiDialog md=new MultiDialog("String_Node_Str",new MultiDialog.BaseItems(){
    public int size(){
      return templates.length + inlineNames.length;
    }
    public String getFormattedName(    int i){
      if (i < inlineNames.length)       return inlineNames[i];
      return templates[i - inlineNames.length].name;
    }
  }
);
  md.addSelected(settings.getSelectedStandardTemplatesList());
  md.showDialog();
  if (md.wasCanceled())   return;
  ArrayList<String> selected=md.getSelectedResults();
  if (selected.isEmpty())   return;
  settings.clearSelectedStandardTemplates();
  settings.addAllSelectedStandardTemplates(selected);
  int count=0;
  final HashSet<String> remaining=new HashSet<String>(selected.size());
  for (int i=0; i < selected.size(); i++) {
    String name=selected.get(i);
    Template t=inlineTemplates.get(name);
    if (t != null) {
      count++;
      map.put(name,t);
    }
 else {
      remaining.add(name);
    }
  }
  if (!remaining.isEmpty()) {
    TurboList<TemplateResource> list=new TurboList<TemplateResource>(remaining.size());
    for (    TemplateResource t : templates) {
      if (remaining.contains(t.name))       list.add(t);
    }
    count+=loadTemplateResources(list.toArray(new TemplateResource[list.size()]));
  }
  if (count > 0)   saveDefaultTemplates();
  IJ.showMessage("String_Node_Str" + TextUtils.pleural(count,"String_Node_Str"));
}