Program: 35452
Project: 35452
Buggy source:
private void showContactCreator(){
  final Window window=new Window();
  window.setPlain(true);
  window.setModal(true);
  window.setBlinkModal(true);
  window.setLayout(new FitLayout());
  window.setSize(700,300);
  window.setHeadingHtml(I18N.CONSTANTS.createContactDialogTitle());
  final ComboBox<ContactModelDTO> contactModelComboBox=Forms.combobox(I18N.CONSTANTS.contactModelLabel(),true,ContactModelDTO.ID,ContactModelDTO.NAME);
  final TextField<String> firstNameField=Forms.text(I18N.CONSTANTS.contactFirstName(),false);
  final TextField<String> familyNameField=Forms.text(I18N.CONSTANTS.contactFamilyName(),false);
  final TextField<String> organizationNameField=Forms.text(I18N.CONSTANTS.contactOrganizationName(),false);
  firstNameField.setVisible(false);
  familyNameField.setVisible(false);
  organizationNameField.setVisible(false);
  final ComboBox<OrgUnitDTO> mainOrgUnitComboBox=Forms.combobox(I18N.CONSTANTS.contactMainOrgUnit(),false,OrgUnitDTO.ID,OrgUnitDTO.FULL_NAME);
  final ListComboBox<OrgUnitDTO> secondaryOrgUnitsComboBox=new ListComboBox<OrgUnitDTO>(OrgUnitDTO.ID,OrgUnitDTO.FULL_NAME);
  secondaryOrgUnitsComboBox.initComponent();
  final AdapterField secondaryOrgUnitsFieldAdapter=Forms.adapter(I18N.CONSTANTS.contactSecondaryOrgUnits(),secondaryOrgUnitsComboBox);
  secondaryOrgUnitsFieldAdapter.setVisible(false);
  dispatch.execute(new GetContactModels(null,Collections.<Integer>emptySet(),true),new AsyncCallback<ListResult<ContactModelDTO>>(){
    @Override public void onFailure(    Throwable caught){
      Log.error("String_Node_Str");
    }
    @Override public void onSuccess(    ListResult<ContactModelDTO> result){
      contactModelComboBox.getStore().add(result.getList());
    }
  }
);
  dispatch.execute(new GetOrgUnits(OrgUnitDTO.Mode.WITH_TREE),new AsyncCallback<ListResult<OrgUnitDTO>>(){
    @Override public void onFailure(    Throwable caught){
      Log.error("String_Node_Str");
    }
    @Override public void onSuccess(    ListResult<OrgUnitDTO> result){
      for (      OrgUnitDTO orgUnitDTO : result.getData()) {
        fillOrgUnitsComboboxes(orgUnitDTO,mainOrgUnitComboBox,secondaryOrgUnitsComboBox);
      }
    }
  }
);
  mainOrgUnitComboBox.addSelectionChangedListener(new SelectionChangedListener<OrgUnitDTO>(){
    @Override public void selectionChanged(    SelectionChangedEvent<OrgUnitDTO> se){
      if (se.getSelectedItem() == null) {
        secondaryOrgUnitsFieldAdapter.setVisible(false);
        return;
      }
      secondaryOrgUnitsFieldAdapter.setVisible(true);
    }
  }
);
  contactModelComboBox.addSelectionChangedListener(new SelectionChangedListener<ContactModelDTO>(){
    @Override public void selectionChanged(    SelectionChangedEvent<ContactModelDTO> event){
      ContactModelType currentType=null;
      if (event.getSelectedItem() != null) {
        currentType=event.getSelectedItem().getType();
      }
      firstNameField.setVisible(currentType == ContactModelType.INDIVIDUAL);
      familyNameField.setVisible(currentType == ContactModelType.INDIVIDUAL);
      organizationNameField.setVisible(currentType == ContactModelType.ORGANIZATION);
      firstNameField.setAllowBlank(currentType != ContactModelType.INDIVIDUAL);
      familyNameField.setAllowBlank(currentType != ContactModelType.INDIVIDUAL);
      organizationNameField.setAllowBlank(currentType != ContactModelType.ORGANIZATION);
    }
  }
);
  org.sigmah.client.ui.widget.button.Button button=Forms.button(I18N.CONSTANTS.createContact());
  final FormPanel formPanel=Forms.panel(200);
  formPanel.add(contactModelComboBox);
  formPanel.add(firstNameField);
  formPanel.add(familyNameField);
  formPanel.add(organizationNameField);
  formPanel.add(mainOrgUnitComboBox);
  formPanel.add(secondaryOrgUnitsFieldAdapter);
  formPanel.getButtonBar().add(button);
  button.addSelectionListener(new SelectionListener<ButtonEvent>(){
    @Override public void componentSelected(    ButtonEvent event){
      if (!formPanel.isValid()) {
        return;
      }
      createContactHandler.handleContactCreation(contactModelComboBox.getValue(),firstNameField.getValue(),familyNameField.getValue(),organizationNameField.getValue(),mainOrgUnitComboBox.getValue(),secondaryOrgUnitsComboBox.getListStore().getModels());
      window.hide();
    }
  }
);
  window.add(formPanel);
  window.show();
}

Fixed version (ground truth):
private void showContactCreator(){
  final Window window=new Window();
  window.setPlain(true);
  window.setModal(true);
  window.setBlinkModal(true);
  window.setLayout(new FitLayout());
  window.setSize(700,300);
  window.setHeadingHtml(I18N.CONSTANTS.createContactDialogTitle());
  final ComboBox<ContactModelDTO> contactModelComboBox=Forms.combobox(I18N.CONSTANTS.contactModelLabel(),true,ContactModelDTO.ID,ContactModelDTO.NAME);
  final TextField<String> emailField=Forms.text(I18N.CONSTANTS.contactEmailAddress(),false);
  final TextField<String> firstNameField=Forms.text(I18N.CONSTANTS.contactFirstName(),false);
  final TextField<String> familyNameField=Forms.text(I18N.CONSTANTS.contactFamilyName(),false);
  final TextField<String> organizationNameField=Forms.text(I18N.CONSTANTS.contactOrganizationName(),false);
  firstNameField.setVisible(false);
  familyNameField.setVisible(false);
  organizationNameField.setVisible(false);
  final ComboBox<OrgUnitDTO> mainOrgUnitComboBox=Forms.combobox(I18N.CONSTANTS.contactMainOrgUnit(),false,OrgUnitDTO.ID,OrgUnitDTO.FULL_NAME);
  final ListComboBox<OrgUnitDTO> secondaryOrgUnitsComboBox=new ListComboBox<OrgUnitDTO>(OrgUnitDTO.ID,OrgUnitDTO.FULL_NAME);
  secondaryOrgUnitsComboBox.initComponent();
  final AdapterField secondaryOrgUnitsFieldAdapter=Forms.adapter(I18N.CONSTANTS.contactSecondaryOrgUnits(),secondaryOrgUnitsComboBox);
  secondaryOrgUnitsFieldAdapter.setVisible(false);
  dispatch.execute(new GetContactModels(null,Collections.<Integer>emptySet(),true),new AsyncCallback<ListResult<ContactModelDTO>>(){
    @Override public void onFailure(    Throwable caught){
      Log.error("String_Node_Str");
    }
    @Override public void onSuccess(    ListResult<ContactModelDTO> result){
      contactModelComboBox.getStore().add(result.getList());
    }
  }
);
  dispatch.execute(new GetOrgUnits(OrgUnitDTO.Mode.WITH_TREE),new AsyncCallback<ListResult<OrgUnitDTO>>(){
    @Override public void onFailure(    Throwable caught){
      Log.error("String_Node_Str");
    }
    @Override public void onSuccess(    ListResult<OrgUnitDTO> result){
      for (      OrgUnitDTO orgUnitDTO : result.getData()) {
        fillOrgUnitsComboboxes(orgUnitDTO,mainOrgUnitComboBox,secondaryOrgUnitsComboBox);
      }
    }
  }
);
  mainOrgUnitComboBox.addSelectionChangedListener(new SelectionChangedListener<OrgUnitDTO>(){
    @Override public void selectionChanged(    SelectionChangedEvent<OrgUnitDTO> se){
      if (se.getSelectedItem() == null) {
        secondaryOrgUnitsFieldAdapter.setVisible(false);
        return;
      }
      secondaryOrgUnitsFieldAdapter.setVisible(true);
    }
  }
);
  contactModelComboBox.addSelectionChangedListener(new SelectionChangedListener<ContactModelDTO>(){
    @Override public void selectionChanged(    SelectionChangedEvent<ContactModelDTO> event){
      ContactModelType currentType=null;
      if (event.getSelectedItem() != null) {
        currentType=event.getSelectedItem().getType();
      }
      firstNameField.setVisible(currentType == ContactModelType.INDIVIDUAL);
      familyNameField.setVisible(currentType == ContactModelType.INDIVIDUAL);
      organizationNameField.setVisible(currentType == ContactModelType.ORGANIZATION);
      firstNameField.setAllowBlank(currentType != ContactModelType.INDIVIDUAL);
      familyNameField.setAllowBlank(currentType != ContactModelType.INDIVIDUAL);
      organizationNameField.setAllowBlank(currentType != ContactModelType.ORGANIZATION);
    }
  }
);
  org.sigmah.client.ui.widget.button.Button button=Forms.button(I18N.CONSTANTS.createContact());
  final FormPanel formPanel=Forms.panel(200);
  formPanel.add(contactModelComboBox);
  formPanel.add(emailField);
  formPanel.add(firstNameField);
  formPanel.add(familyNameField);
  formPanel.add(organizationNameField);
  formPanel.add(mainOrgUnitComboBox);
  formPanel.add(secondaryOrgUnitsFieldAdapter);
  formPanel.getButtonBar().add(button);
  button.addSelectionListener(new SelectionListener<ButtonEvent>(){
    @Override public void componentSelected(    ButtonEvent event){
      if (!formPanel.isValid()) {
        return;
      }
      createContactHandler.handleContactCreation(contactModelComboBox.getValue(),emailField.getValue(),firstNameField.getValue(),familyNameField.getValue(),organizationNameField.getValue(),mainOrgUnitComboBox.getValue(),secondaryOrgUnitsComboBox.getListStore().getModels());
      window.hide();
    }
  }
);
  window.add(formPanel);
  window.show();
}