Program: 2189
Project: 2189
Buggy source:
public AlertingConfigInputFormPanel(final String name,final FeedbackPanel feedback,final ModalWindow window,final AlertingConfigsPanel parentPanel,final AlertingConfigFormModel alertingConfigFormModel,final ModalMode mode){
  super(name);
  boolean formEnabled=false;
  if (mode == null) {
    throw new IllegalStateException();
  }
 else   if (mode.equals(INSERT)) {
    alertingConfigFormModel.getNotificationGroupList().add(new ConfDataNotifGroup());
    ConfDataDAO confDataDAO=((AreciboAlertManager)getApplication()).getConfDataDAO();
    formEnabled=(alertingConfigFormModel.initNotificationGroupListChoices(confDataDAO) && alertingConfigFormModel.initManagingKeyListChoices(confDataDAO));
  }
 else   if (mode.equals(UPDATE)) {
    ConfDataDAO confDataDAO=((AreciboAlertManager)getApplication()).getConfDataDAO();
    formEnabled=(alertingConfigFormModel.initNotificationGroupListChoices(confDataDAO) && alertingConfigFormModel.initNotificationGroupList(confDataDAO) && alertingConfigFormModel.initManagingKeyListChoices(confDataDAO)&& alertingConfigFormModel.initManagingKeyList(confDataDAO));
  }
 else {
    throw new IllegalStateException("String_Node_Str" + mode);
  }
  final Form<AlertingConfigFormModel> form=new Form<AlertingConfigFormModel>("String_Node_Str",new CompoundPropertyModel<AlertingConfigFormModel>(alertingConfigFormModel));
  form.setOutputMarkupId(true);
  add(form);
  if (!formEnabled) {
    feedback.error("String_Node_Str");
    form.setEnabled(false);
  }
  final RequiredTextField<String> alertingConfigName=new RequiredTextField<String>("String_Node_Str");
  form.add(alertingConfigName);
  final RequiredTextField<Long> notifRepeatIntervalMs=new RequiredTextField<Long>("String_Node_Str");
  notifRepeatIntervalMs.add(new MinimumValidator<Long>(0L));
  notifRepeatIntervalMs.setOutputMarkupPlaceholderTag(true);
  form.add(notifRepeatIntervalMs);
  final WebMarkupContainerWithAssociatedMarkup notifRepeatIntervalMsLabel=new WebMarkupContainerWithAssociatedMarkup("String_Node_Str");
  notifRepeatIntervalMsLabel.setOutputMarkupPlaceholderTag(true);
  form.add(notifRepeatIntervalMsLabel);
  if (alertingConfigFormModel.getNotifRepeatMode() == null || alertingConfigFormModel.getNotifRepeatMode().equals(NotificationRepeatMode.NO_REPEAT)) {
    notifRepeatIntervalMs.setVisible(false);
    notifRepeatIntervalMsLabel.setVisible(false);
  }
  final DropDownChoice<NotificationRepeatMode> notifRepeatMode=new DropDownChoice<NotificationRepeatMode>("String_Node_Str",new PropertyModel<NotificationRepeatMode>(alertingConfigFormModel,"String_Node_Str"),Arrays.asList(NotificationRepeatMode.values()));
  notifRepeatMode.setRequired(true);
  notifRepeatMode.setOutputMarkupId(true);
  notifRepeatMode.add(new AjaxFormComponentUpdatingBehavior("String_Node_Str"){
    @Override protected void onUpdate(    AjaxRequestTarget target){
      NotificationRepeatMode mode=notifRepeatMode.getModelObject();
      if (mode == null || mode.equals(NotificationRepeatMode.NO_REPEAT)) {
        alertingConfigFormModel.setNotifRepeatIntervalMs(null);
        notifRepeatIntervalMsLabel.setVisible(false);
        notifRepeatIntervalMs.setVisible(false);
        target.addComponent(notifRepeatIntervalMsLabel);
        target.addComponent(notifRepeatIntervalMs);
      }
 else {
        notifRepeatIntervalMsLabel.setVisible(true);
        notifRepeatIntervalMs.setVisible(true);
        target.addComponent(notifRepeatIntervalMsLabel);
        target.addComponent(notifRepeatIntervalMs);
      }
    }
  }
);
  form.add(notifRepeatMode);
  final CheckBox notifOnRecovery=new CheckBox("String_Node_Str");
  form.add(notifOnRecovery);
  final CheckBox enabled=new CheckBox("String_Node_Str");
  form.add(enabled);
  final WebMarkupContainer notificationGroupListContainer=new WebMarkupContainer("String_Node_Str");
  notificationGroupListContainer.setOutputMarkupId(true);
  form.add(notificationGroupListContainer);
  final ListView<ConfDataNotifGroup> notificationGroupList=new ListView<ConfDataNotifGroup>("String_Node_Str",alertingConfigFormModel.getNotificationGroupList()){
    private Component hiddenRemoveButton=null;
    @Override public void populateItem(    final ListItem item){
      final ListView<ConfDataNotifGroup> thisList=this;
      final ConfDataNotifGroup group=(ConfDataNotifGroup)item.getModelObject();
      final DropDownChoice<String> notificationGroup=new DropDownChoice<String>("String_Node_Str",new Model<String>(group.getLabel()),alertingConfigFormModel.getNotificationGroupNameList());
      notificationGroup.setRequired(true);
      notificationGroup.setOutputMarkupId(true);
      notificationGroup.add(new AjaxFormComponentUpdatingBehavior("String_Node_Str"){
        @Override protected void onUpdate(        AjaxRequestTarget target){
          String selectedGroupName=notificationGroup.getModelObject();
          ConfDataNotifGroup selectedGroup=alertingConfigFormModel.getNotificationGroupByGroupName(selectedGroupName);
          group.setPropertiesFromMap(selectedGroup.toPropertiesMap());
          target.addComponent(notificationGroup);
        }
      }
);
      item.add(notificationGroup);
      AjaxFallbackButton removeNotificationGroupButton=new AjaxFallbackButton("String_Node_Str",form){
        @Override protected void onSubmit(        AjaxRequestTarget target,        Form<?> form){
          alertingConfigFormModel.getNotificationGroupList().remove(item.getIndex());
          thisList.modelChanged();
          target.addComponent(notificationGroupListContainer);
        }
      }
;
      if (alertingConfigFormModel.getNotificationGroupList().size() <= 1) {
        removeNotificationGroupButton.setVisible(false);
        this.hiddenRemoveButton=removeNotificationGroupButton;
      }
 else {
        removeNotificationGroupButton.setVisible(true);
        if (this.hiddenRemoveButton != null) {
          this.hiddenRemoveButton.setVisible(true);
          this.hiddenRemoveButton=null;
        }
      }
      removeNotificationGroupButton.setDefaultFormProcessing(false);
      removeNotificationGroupButton.setOutputMarkupPlaceholderTag(true);
      item.add(removeNotificationGroupButton);
    }
  }
;
  notificationGroupList.setOutputMarkupId(true);
  notificationGroupListContainer.add(notificationGroupList);
  final AjaxFallbackButton addNotificationGroupButton=new AjaxFallbackButton("String_Node_Str",form){
    @Override protected void onSubmit(    AjaxRequestTarget target,    Form<?> form){
      alertingConfigFormModel.getNotificationGroupList().add(new ConfDataNotifGroup());
      notificationGroupList.modelChanged();
      target.addComponent(notificationGroupListContainer);
    }
  }
;
  addNotificationGroupButton.setDefaultFormProcessing(false);
  form.add(addNotificationGroupButton);
  final WebMarkupContainer managingKeyListContainer=new WebMarkupContainer("String_Node_Str");
  managingKeyListContainer.setOutputMarkupId(true);
  form.add(managingKeyListContainer);
  final ListView<ConfDataManagingKey> managingKeyList=new ListView<ConfDataManagingKey>("String_Node_Str",alertingConfigFormModel.getManagingKeyList()){
    @Override public void populateItem(    final ListItem item){
      final ListView<ConfDataManagingKey> thisList=this;
      final ConfDataManagingKey key=(ConfDataManagingKey)item.getModelObject();
      final DropDownChoice<String> managingKey=new DropDownChoice<String>("String_Node_Str",new Model<String>(key.getKey()),alertingConfigFormModel.getManagingKeyNameList());
      managingKey.setRequired(true);
      managingKey.setOutputMarkupId(true);
      managingKey.add(new AjaxFormComponentUpdatingBehavior("String_Node_Str"){
        @Override protected void onUpdate(        AjaxRequestTarget target){
          String selectedKeyName=managingKey.getModelObject();
          ConfDataManagingKey selectedKey=alertingConfigFormModel.getManagingKeyByManagingKeyName(selectedKeyName);
          key.setPropertiesFromMap(selectedKey.toPropertiesMap());
          target.addComponent(managingKey);
        }
      }
);
      item.add(managingKey);
      AjaxFallbackButton removeManagingKeyButton=new AjaxFallbackButton("String_Node_Str",form){
        @Override protected void onSubmit(        AjaxRequestTarget target,        Form<?> form){
          alertingConfigFormModel.getManagingKeyList().remove(item.getIndex());
          thisList.modelChanged();
          target.addComponent(managingKeyListContainer);
        }
      }
;
      removeManagingKeyButton.setDefaultFormProcessing(false);
      removeManagingKeyButton.setOutputMarkupPlaceholderTag(true);
      item.add(removeManagingKeyButton);
    }
  }
;
  managingKeyList.setOutputMarkupId(true);
  managingKeyListContainer.add(managingKeyList);
  final AjaxFallbackButton addManagingKeyButton=new AjaxFallbackButton("String_Node_Str",form){
    @Override protected void onSubmit(    AjaxRequestTarget target,    Form<?> form){
      alertingConfigFormModel.getManagingKeyList().add(new ConfDataManagingKey());
      managingKeyList.modelChanged();
      target.addComponent(managingKeyListContainer);
    }
  }
;
  addManagingKeyButton.setDefaultFormProcessing(false);
  form.add(addManagingKeyButton);
  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){
      AlertingConfigFormModel notifGroup=(AlertingConfigFormModel)form.getModel().getObject();
      try {
        ConfDataDAO confDataDAO=((AreciboAlertManager)getApplication()).getConfDataDAO();
        boolean success;
        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 AlertingConfigInputFormPanel(final String name,final FeedbackPanel feedback,final ModalWindow window,final AlertingConfigsPanel parentPanel,final AlertingConfigFormModel alertingConfigFormModel,final ModalMode mode){
  super(name);
  boolean formEnabled=false;
  if (mode == null) {
    throw new IllegalStateException();
  }
 else   if (mode.equals(INSERT)) {
    alertingConfigFormModel.getNotificationGroupList().add(new ConfDataNotifGroup());
    ConfDataDAO confDataDAO=((AreciboAlertManager)getApplication()).getConfDataDAO();
    formEnabled=(alertingConfigFormModel.initNotificationGroupListChoices(confDataDAO) && alertingConfigFormModel.initManagingKeyListChoices(confDataDAO));
  }
 else   if (mode.equals(UPDATE)) {
    ConfDataDAO confDataDAO=((AreciboAlertManager)getApplication()).getConfDataDAO();
    formEnabled=(alertingConfigFormModel.initNotificationGroupListChoices(confDataDAO) && alertingConfigFormModel.initNotificationGroupList(confDataDAO) && alertingConfigFormModel.initManagingKeyListChoices(confDataDAO)&& alertingConfigFormModel.initManagingKeyList(confDataDAO));
  }
 else {
    throw new IllegalStateException("String_Node_Str" + mode);
  }
  final Form<AlertingConfigFormModel> form=new Form<AlertingConfigFormModel>("String_Node_Str",new CompoundPropertyModel<AlertingConfigFormModel>(alertingConfigFormModel));
  form.setOutputMarkupId(true);
  add(form);
  if (!formEnabled) {
    feedback.error("String_Node_Str");
    form.setEnabled(false);
  }
  final RequiredTextField<String> alertingConfigName=new RequiredTextField<String>("String_Node_Str");
  form.add(alertingConfigName);
  final RequiredTextField<Long> notifRepeatIntervalMs=new RequiredTextField<Long>("String_Node_Str");
  notifRepeatIntervalMs.add(new MinimumValidator<Long>(0L));
  notifRepeatIntervalMs.setOutputMarkupPlaceholderTag(true);
  form.add(notifRepeatIntervalMs);
  final WebMarkupContainerWithAssociatedMarkup notifRepeatIntervalMsLabel=new WebMarkupContainerWithAssociatedMarkup("String_Node_Str");
  notifRepeatIntervalMsLabel.setOutputMarkupPlaceholderTag(true);
  form.add(notifRepeatIntervalMsLabel);
  if (alertingConfigFormModel.getNotifRepeatMode() == null || alertingConfigFormModel.getNotifRepeatMode().equals(NotificationRepeatMode.NO_REPEAT)) {
    notifRepeatIntervalMs.setVisible(false);
    notifRepeatIntervalMsLabel.setVisible(false);
  }
  final DropDownChoice<NotificationRepeatMode> notifRepeatMode=new DropDownChoice<NotificationRepeatMode>("String_Node_Str",new PropertyModel<NotificationRepeatMode>(alertingConfigFormModel,"String_Node_Str"),Arrays.asList(NotificationRepeatMode.values()));
  notifRepeatMode.setRequired(true);
  notifRepeatMode.setOutputMarkupId(true);
  notifRepeatMode.add(new AjaxFormComponentUpdatingBehavior("String_Node_Str"){
    @Override protected void onUpdate(    AjaxRequestTarget target){
      NotificationRepeatMode mode=notifRepeatMode.getModelObject();
      if (mode == null || mode.equals(NotificationRepeatMode.NO_REPEAT)) {
        alertingConfigFormModel.setNotifRepeatIntervalMs(null);
        notifRepeatIntervalMsLabel.setVisible(false);
        notifRepeatIntervalMs.setVisible(false);
        target.addComponent(notifRepeatIntervalMsLabel);
        target.addComponent(notifRepeatIntervalMs);
      }
 else {
        notifRepeatIntervalMsLabel.setVisible(true);
        notifRepeatIntervalMs.setVisible(true);
        target.addComponent(notifRepeatIntervalMsLabel);
        target.addComponent(notifRepeatIntervalMs);
      }
    }
  }
);
  form.add(notifRepeatMode);
  final CheckBox notifOnRecovery=new CheckBox("String_Node_Str");
  form.add(notifOnRecovery);
  final CheckBox enabled=new CheckBox("String_Node_Str");
  form.add(enabled);
  final WebMarkupContainer notificationGroupListContainer=new WebMarkupContainer("String_Node_Str");
  notificationGroupListContainer.setOutputMarkupId(true);
  form.add(notificationGroupListContainer);
  final ListView<ConfDataNotifGroup> notificationGroupList=new ListView<ConfDataNotifGroup>("String_Node_Str",alertingConfigFormModel.getNotificationGroupList()){
    private Component hiddenRemoveButton=null;
    @Override public void populateItem(    final ListItem item){
      final ListView<ConfDataNotifGroup> thisList=this;
      final ConfDataNotifGroup group=(ConfDataNotifGroup)item.getModelObject();
      final DropDownChoice<String> notificationGroup=new DropDownChoice<String>("String_Node_Str",new Model<String>(group.getLabel()),alertingConfigFormModel.getNotificationGroupNameList());
      notificationGroup.setRequired(true);
      notificationGroup.setOutputMarkupId(true);
      notificationGroup.add(new AjaxFormComponentUpdatingBehavior("String_Node_Str"){
        @Override protected void onUpdate(        AjaxRequestTarget target){
          String selectedGroupName=notificationGroup.getModelObject();
          ConfDataNotifGroup selectedGroup=alertingConfigFormModel.getNotificationGroupByGroupName(selectedGroupName);
          group.populatePropertiesFromMap(selectedGroup.toPropertiesMap());
          target.addComponent(notificationGroup);
        }
      }
);
      item.add(notificationGroup);
      AjaxFallbackButton removeNotificationGroupButton=new AjaxFallbackButton("String_Node_Str",form){
        @Override protected void onSubmit(        AjaxRequestTarget target,        Form<?> form){
          alertingConfigFormModel.getNotificationGroupList().remove(item.getIndex());
          thisList.modelChanged();
          target.addComponent(notificationGroupListContainer);
        }
      }
;
      if (alertingConfigFormModel.getNotificationGroupList().size() <= 1) {
        removeNotificationGroupButton.setVisible(false);
        this.hiddenRemoveButton=removeNotificationGroupButton;
      }
 else {
        removeNotificationGroupButton.setVisible(true);
        if (this.hiddenRemoveButton != null) {
          this.hiddenRemoveButton.setVisible(true);
          this.hiddenRemoveButton=null;
        }
      }
      removeNotificationGroupButton.setDefaultFormProcessing(false);
      removeNotificationGroupButton.setOutputMarkupPlaceholderTag(true);
      item.add(removeNotificationGroupButton);
    }
  }
;
  notificationGroupList.setOutputMarkupId(true);
  notificationGroupListContainer.add(notificationGroupList);
  final AjaxFallbackButton addNotificationGroupButton=new AjaxFallbackButton("String_Node_Str",form){
    @Override protected void onSubmit(    AjaxRequestTarget target,    Form<?> form){
      alertingConfigFormModel.getNotificationGroupList().add(new ConfDataNotifGroup());
      notificationGroupList.modelChanged();
      target.addComponent(notificationGroupListContainer);
    }
  }
;
  addNotificationGroupButton.setDefaultFormProcessing(false);
  form.add(addNotificationGroupButton);
  final WebMarkupContainer managingKeyListContainer=new WebMarkupContainer("String_Node_Str");
  managingKeyListContainer.setOutputMarkupId(true);
  form.add(managingKeyListContainer);
  final ListView<ConfDataManagingKey> managingKeyList=new ListView<ConfDataManagingKey>("String_Node_Str",alertingConfigFormModel.getManagingKeyList()){
    @Override public void populateItem(    final ListItem item){
      final ListView<ConfDataManagingKey> thisList=this;
      final ConfDataManagingKey key=(ConfDataManagingKey)item.getModelObject();
      final DropDownChoice<String> managingKey=new DropDownChoice<String>("String_Node_Str",new Model<String>(key.getKey()),alertingConfigFormModel.getManagingKeyNameList());
      managingKey.setRequired(true);
      managingKey.setOutputMarkupId(true);
      managingKey.add(new AjaxFormComponentUpdatingBehavior("String_Node_Str"){
        @Override protected void onUpdate(        AjaxRequestTarget target){
          String selectedKeyName=managingKey.getModelObject();
          ConfDataManagingKey selectedKey=alertingConfigFormModel.getManagingKeyByManagingKeyName(selectedKeyName);
          key.populatePropertiesFromMap(selectedKey.toPropertiesMap());
          target.addComponent(managingKey);
        }
      }
);
      item.add(managingKey);
      AjaxFallbackButton removeManagingKeyButton=new AjaxFallbackButton("String_Node_Str",form){
        @Override protected void onSubmit(        AjaxRequestTarget target,        Form<?> form){
          alertingConfigFormModel.getManagingKeyList().remove(item.getIndex());
          thisList.modelChanged();
          target.addComponent(managingKeyListContainer);
        }
      }
;
      removeManagingKeyButton.setDefaultFormProcessing(false);
      removeManagingKeyButton.setOutputMarkupPlaceholderTag(true);
      item.add(removeManagingKeyButton);
    }
  }
;
  managingKeyList.setOutputMarkupId(true);
  managingKeyListContainer.add(managingKeyList);
  final AjaxFallbackButton addManagingKeyButton=new AjaxFallbackButton("String_Node_Str",form){
    @Override protected void onSubmit(    AjaxRequestTarget target,    Form<?> form){
      alertingConfigFormModel.getManagingKeyList().add(new ConfDataManagingKey());
      managingKeyList.modelChanged();
      target.addComponent(managingKeyListContainer);
    }
  }
;
  addManagingKeyButton.setDefaultFormProcessing(false);
  form.add(addManagingKeyButton);
  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){
      AlertingConfigFormModel notifGroup=(AlertingConfigFormModel)form.getModel().getObject();
      try {
        ConfDataDAO confDataDAO=((AreciboAlertManager)getApplication()).getConfDataDAO();
        boolean success;
        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);
}