Program: 2195
Project: 2195
Buggy source:
public NotificationGroupInputFormPanel(final String name,final FeedbackPanel feedback,final ModalWindow window,final NotificationGroupsPanel parentPanel,final NotificationGroupFormModel notifGroupFormModel,final ModalMode mode){
  super(name);
  boolean formEnabled=true;
  if (mode == null) {
    throw new IllegalStateException();
  }
 else   if (mode.equals(INSERT)) {
    notifGroupFormModel.getNotificationConfigList().add(new ConfDataNotifConfig());
    ConfDataDAO confDataDAO=((AreciboAlertManager)getApplication()).getConfDataDAO();
    formEnabled=notifGroupFormModel.initNotificationConfigListChoices(confDataDAO);
  }
 else   if (mode.equals(UPDATE)) {
    ConfDataDAO confDataDAO=((AreciboAlertManager)getApplication()).getConfDataDAO();
    formEnabled=(notifGroupFormModel.initNotificationConfigList(confDataDAO) && notifGroupFormModel.initNotificationConfigListChoices(confDataDAO));
  }
  final Form<NotificationGroupFormModel> form=new Form<NotificationGroupFormModel>("String_Node_Str",new CompoundPropertyModel<NotificationGroupFormModel>(notifGroupFormModel));
  form.setOutputMarkupId(true);
  add(form);
  if (!formEnabled) {
    feedback.error("String_Node_Str");
    form.setEnabled(false);
  }
  final RequiredTextField<String> groupName=new RequiredTextField<String>("String_Node_Str");
  form.add(groupName);
  final CheckBox enabled=new CheckBox("String_Node_Str");
  form.add(enabled);
  final WebMarkupContainer notificationConfigListContainer=new WebMarkupContainer("String_Node_Str");
  notificationConfigListContainer.setOutputMarkupId(true);
  form.add(notificationConfigListContainer);
  final ListView<ConfDataNotifConfig> notificationConfigList=new ListView<ConfDataNotifConfig>("String_Node_Str",notifGroupFormModel.getNotificationConfigList()){
    private Component hiddenRemoveButton=null;
    @Override public void populateItem(    final ListItem item){
      final ListView<ConfDataNotifConfig> thisList=this;
      final ConfDataNotifConfig config=(ConfDataNotifConfig)item.getModelObject();
      final DropDownChoice<String> notificationAddress=new DropDownChoice<String>("String_Node_Str",new PropertyModel<String>(config,"String_Node_Str"),notifGroupFormModel.getNotificationConfigAddressList(config.getPersonId()));
      notificationAddress.setRequired(true);
      notificationAddress.setOutputMarkupId(true);
      notificationAddress.add(new AjaxFormComponentUpdatingBehavior("String_Node_Str"){
        @Override protected void onUpdate(        AjaxRequestTarget target){
          String selectedAddress=(String)notificationAddress.getModelObject();
          ConfDataNotifConfig notificationConfig=notifGroupFormModel.getNotificationConfigByAddress(selectedAddress);
          config.setPropertiesFromMap(notificationConfig.toPropertiesMap());
        }
      }
);
      item.add(notificationAddress);
      final DropDownChoice<String> notificationPerson=new DropDownChoice<String>("String_Node_Str",new Model<String>(notifGroupFormModel.getPersonNickName(config.getPersonId())),notifGroupFormModel.getPersonList());
      notificationPerson.setRequired(true);
      notificationPerson.setOutputMarkupId(true);
      notificationPerson.add(new AjaxFormComponentUpdatingBehavior("String_Node_Str"){
        @Override protected void onUpdate(        AjaxRequestTarget target){
          String selectedPerson=notificationPerson.getModelObject();
          List<String> choices=notifGroupFormModel.getNotificationConfigAddressList(selectedPerson);
          if (choices.size() == 1) {
            ConfDataNotifConfig notificationConfig=notifGroupFormModel.getNotificationConfigByAddress(choices.get(0));
            config.setPropertiesFromMap(notificationConfig.toPropertiesMap());
          }
 else           config.setAddress(null);
          notificationAddress.setChoices(choices);
          notificationAddress.modelChanged();
          target.addComponent(notificationAddress);
        }
      }
);
      item.add(notificationPerson);
      AjaxFallbackButton removeNotificationConfigButton=new AjaxFallbackButton("String_Node_Str",form){
        @Override protected void onSubmit(        AjaxRequestTarget target,        Form<?> form){
          notifGroupFormModel.getNotificationConfigList().remove(item.getIndex());
          thisList.modelChanged();
          target.addComponent(notificationConfigListContainer);
        }
      }
;
      if (notifGroupFormModel.getNotificationConfigList().size() <= 1) {
        removeNotificationConfigButton.setVisible(false);
        this.hiddenRemoveButton=removeNotificationConfigButton;
      }
 else {
        removeNotificationConfigButton.setVisible(true);
        if (this.hiddenRemoveButton != null) {
          this.hiddenRemoveButton.setVisible(true);
          this.hiddenRemoveButton=null;
        }
      }
      removeNotificationConfigButton.setOutputMarkupPlaceholderTag(true);
      removeNotificationConfigButton.setDefaultFormProcessing(false);
      item.add(removeNotificationConfigButton);
    }
  }
;
  notificationConfigList.setOutputMarkupId(true);
  notificationConfigListContainer.add(notificationConfigList);
  final AjaxFallbackButton addNotificationConfigButton=new AjaxFallbackButton("String_Node_Str",form){
    @Override protected void onSubmit(    AjaxRequestTarget target,    Form<?> form){
      notifGroupFormModel.getNotificationConfigList().add(new ConfDataNotifConfig());
      notificationConfigList.modelChanged();
      target.addComponent(notificationConfigListContainer);
    }
  }
;
  addNotificationConfigButton.setDefaultFormProcessing(false);
  form.add(addNotificationConfigButton);
  final Label warningLabel=new Label("String_Node_Str","String_Node_Str");
  warningLabel.setOutputMarkupPlaceholderTag(true);
  warningLabel.setVisible(false);
  form.add(warningLabel);
  form.add(new AjaxFallbackButton("String_Node_Str",form){
    @Override protected void onSubmit(    AjaxRequestTarget target,    Form<?> form){
      NotificationGroupFormModel notifGroup=(NotificationGroupFormModel)form.getModel().getObject();
      try {
        ConfDataDAO confDataDAO=((AreciboAlertManager)getApplication()).getConfDataDAO();
        boolean success;
        if (mode == null) {
          throw new IllegalStateException();
        }
 else         if (mode.equals(INSERT)) {
          success=notifGroup.insert(confDataDAO);
        }
 else         if (mode.equals(UPDATE)) {
          success=notifGroup.update(confDataDAO);
        }
 else {
          throw new IllegalStateException("String_Node_Str" + mode);
        }
        String statusMessage=notifGroup.getLastStatusMessage();
        if (success) {
          window.close(target);
          parentPanel.sendInfoFeedback(statusMessage);
        }
 else {
          error(statusMessage);
          warningLabel.setVisible(true);
          target.addComponent(warningLabel);
        }
        log.info(statusMessage);
      }
 catch (      Exception e) {
        log.warn(e);
        error(e);
        warningLabel.setVisible(true);
        target.addComponent(warningLabel);
      }
      target.addComponent(feedback);
    }
    @Override protected void onError(    AjaxRequestTarget target,    Form<?> form){
      warningLabel.setVisible(true);
      target.addComponent(warningLabel);
      target.addComponent(feedback);
    }
  }
);
  AjaxFallbackButton cancelButton=new AjaxFallbackButton("String_Node_Str",form){
    @Override protected void onSubmit(    AjaxRequestTarget target,    Form<?> form){
      window.close(target);
    }
  }
;
  cancelButton.setDefaultFormProcessing(false);
  form.add(cancelButton);
}

Fixed version (ground truth):
public NotificationGroupInputFormPanel(final String name,final FeedbackPanel feedback,final ModalWindow window,final NotificationGroupsPanel parentPanel,final NotificationGroupFormModel notifGroupFormModel,final ModalMode mode){
  super(name);
  boolean formEnabled=true;
  if (mode == null) {
    throw new IllegalStateException();
  }
 else   if (mode.equals(INSERT)) {
    notifGroupFormModel.getNotificationConfigList().add(new ConfDataNotifConfig());
    ConfDataDAO confDataDAO=((AreciboAlertManager)getApplication()).getConfDataDAO();
    formEnabled=notifGroupFormModel.initNotificationConfigListChoices(confDataDAO);
  }
 else   if (mode.equals(UPDATE)) {
    ConfDataDAO confDataDAO=((AreciboAlertManager)getApplication()).getConfDataDAO();
    formEnabled=(notifGroupFormModel.initNotificationConfigList(confDataDAO) && notifGroupFormModel.initNotificationConfigListChoices(confDataDAO));
  }
  final Form<NotificationGroupFormModel> form=new Form<NotificationGroupFormModel>("String_Node_Str",new CompoundPropertyModel<NotificationGroupFormModel>(notifGroupFormModel));
  form.setOutputMarkupId(true);
  add(form);
  if (!formEnabled) {
    feedback.error("String_Node_Str");
    form.setEnabled(false);
  }
  final RequiredTextField<String> groupName=new RequiredTextField<String>("String_Node_Str");
  form.add(groupName);
  final CheckBox enabled=new CheckBox("String_Node_Str");
  form.add(enabled);
  final WebMarkupContainer notificationConfigListContainer=new WebMarkupContainer("String_Node_Str");
  notificationConfigListContainer.setOutputMarkupId(true);
  form.add(notificationConfigListContainer);
  final ListView<ConfDataNotifConfig> notificationConfigList=new ListView<ConfDataNotifConfig>("String_Node_Str",notifGroupFormModel.getNotificationConfigList()){
    private Component hiddenRemoveButton=null;
    @Override public void populateItem(    final ListItem item){
      final ListView<ConfDataNotifConfig> thisList=this;
      final ConfDataNotifConfig config=(ConfDataNotifConfig)item.getModelObject();
      final DropDownChoice<String> notificationAddress=new DropDownChoice<String>("String_Node_Str",new PropertyModel<String>(config,"String_Node_Str"),notifGroupFormModel.getNotificationConfigAddressList(config.getPersonId()));
      notificationAddress.setRequired(true);
      notificationAddress.setOutputMarkupId(true);
      notificationAddress.add(new AjaxFormComponentUpdatingBehavior("String_Node_Str"){
        @Override protected void onUpdate(        AjaxRequestTarget target){
          String selectedAddress=(String)notificationAddress.getModelObject();
          ConfDataNotifConfig notificationConfig=notifGroupFormModel.getNotificationConfigByAddress(selectedAddress);
          config.populatePropertiesFromMap(notificationConfig.toPropertiesMap());
        }
      }
);
      item.add(notificationAddress);
      final DropDownChoice<String> notificationPerson=new DropDownChoice<String>("String_Node_Str",new Model<String>(notifGroupFormModel.getPersonNickName(config.getPersonId())),notifGroupFormModel.getPersonList());
      notificationPerson.setRequired(true);
      notificationPerson.setOutputMarkupId(true);
      notificationPerson.add(new AjaxFormComponentUpdatingBehavior("String_Node_Str"){
        @Override protected void onUpdate(        AjaxRequestTarget target){
          String selectedPerson=notificationPerson.getModelObject();
          List<String> choices=notifGroupFormModel.getNotificationConfigAddressList(selectedPerson);
          if (choices.size() == 1) {
            ConfDataNotifConfig notificationConfig=notifGroupFormModel.getNotificationConfigByAddress(choices.get(0));
            config.populatePropertiesFromMap(notificationConfig.toPropertiesMap());
          }
 else           config.setAddress(null);
          notificationAddress.setChoices(choices);
          notificationAddress.modelChanged();
          target.addComponent(notificationAddress);
        }
      }
);
      item.add(notificationPerson);
      AjaxFallbackButton removeNotificationConfigButton=new AjaxFallbackButton("String_Node_Str",form){
        @Override protected void onSubmit(        AjaxRequestTarget target,        Form<?> form){
          notifGroupFormModel.getNotificationConfigList().remove(item.getIndex());
          thisList.modelChanged();
          target.addComponent(notificationConfigListContainer);
        }
      }
;
      if (notifGroupFormModel.getNotificationConfigList().size() <= 1) {
        removeNotificationConfigButton.setVisible(false);
        this.hiddenRemoveButton=removeNotificationConfigButton;
      }
 else {
        removeNotificationConfigButton.setVisible(true);
        if (this.hiddenRemoveButton != null) {
          this.hiddenRemoveButton.setVisible(true);
          this.hiddenRemoveButton=null;
        }
      }
      removeNotificationConfigButton.setOutputMarkupPlaceholderTag(true);
      removeNotificationConfigButton.setDefaultFormProcessing(false);
      item.add(removeNotificationConfigButton);
    }
  }
;
  notificationConfigList.setOutputMarkupId(true);
  notificationConfigListContainer.add(notificationConfigList);
  final AjaxFallbackButton addNotificationConfigButton=new AjaxFallbackButton("String_Node_Str",form){
    @Override protected void onSubmit(    AjaxRequestTarget target,    Form<?> form){
      notifGroupFormModel.getNotificationConfigList().add(new ConfDataNotifConfig());
      notificationConfigList.modelChanged();
      target.addComponent(notificationConfigListContainer);
    }
  }
;
  addNotificationConfigButton.setDefaultFormProcessing(false);
  form.add(addNotificationConfigButton);
  final Label warningLabel=new Label("String_Node_Str","String_Node_Str");
  warningLabel.setOutputMarkupPlaceholderTag(true);
  warningLabel.setVisible(false);
  form.add(warningLabel);
  form.add(new AjaxFallbackButton("String_Node_Str",form){
    @Override protected void onSubmit(    AjaxRequestTarget target,    Form<?> form){
      NotificationGroupFormModel notifGroup=(NotificationGroupFormModel)form.getModel().getObject();
      try {
        ConfDataDAO confDataDAO=((AreciboAlertManager)getApplication()).getConfDataDAO();
        boolean success;
        if (mode == null) {
          throw new IllegalStateException();
        }
 else         if (mode.equals(INSERT)) {
          success=notifGroup.insert(confDataDAO);
        }
 else         if (mode.equals(UPDATE)) {
          success=notifGroup.update(confDataDAO);
        }
 else {
          throw new IllegalStateException("String_Node_Str" + mode);
        }
        String statusMessage=notifGroup.getLastStatusMessage();
        if (success) {
          window.close(target);
          parentPanel.sendInfoFeedback(statusMessage);
        }
 else {
          error(statusMessage);
          warningLabel.setVisible(true);
          target.addComponent(warningLabel);
        }
        log.info(statusMessage);
      }
 catch (      Exception e) {
        log.warn(e);
        error(e);
        warningLabel.setVisible(true);
        target.addComponent(warningLabel);
      }
      target.addComponent(feedback);
    }
    @Override protected void onError(    AjaxRequestTarget target,    Form<?> form){
      warningLabel.setVisible(true);
      target.addComponent(warningLabel);
      target.addComponent(feedback);
    }
  }
);
  AjaxFallbackButton cancelButton=new AjaxFallbackButton("String_Node_Str",form){
    @Override protected void onSubmit(    AjaxRequestTarget target,    Form<?> form){
      window.close(target);
    }
  }
;
  cancelButton.setDefaultFormProcessing(false);
  form.add(cancelButton);
}