Program: 95397
Project: 95397
Buggy source:
/** 
 * {@inheritDoc}createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) 
 */
protected void createButtonsForButtonBar(Composite parent){
  m_addButton=createButton(parent,ADD,m_addButtonText,true);
  m_addButton.addSelectionListener(new SelectionAdapter(){
    public void widgetSelected(    SelectionEvent e){
      notifyListener();
      setReturnCode(ADD);
      close();
    }
  }
);
  TreeViewer tv=m_testcaseTreeComposite.getTreeViewer();
  tv.addSelectionChangedListener(new ISelectionChangedListener(){
    public void selectionChanged(    SelectionChangedEvent e){
      if (e.getSelection() != null) {
        m_addButton.setEnabled(true);
      }
    }
  }
);
  tv.addSelectionChangedListener(new ISelectionChangedListener(){
    public void selectionChanged(    SelectionChangedEvent event){
      m_addButton.setEnabled(checkDataValidityAndSetErrorMessage());
    }
  }
);
  tv.addDoubleClickListener(new IDoubleClickListener(){
    public void doubleClick(    DoubleClickEvent event){
      if (!m_addButton.getEnabled()) {
        return;
      }
      notifyListener();
      setReturnCode(ADD);
      close();
    }
  }
);
  if (m_preSelect != null) {
    tv.getControl().setFocus();
    tv.setSelection(new StructuredSelection(m_preSelect));
  }
  Button cancelButton=createButton(parent,CANCEL,Messages.TestCaseTableDialogCancel,false);
  cancelButton.addSelectionListener(new SelectionAdapter(){
    public void widgetSelected(    SelectionEvent e){
      setReturnCode(CANCEL);
      close();
    }
  }
);
  m_addButton.setEnabled(checkDataValidityAndSetErrorMessage());
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) 
 */
protected void createButtonsForButtonBar(Composite parent){
  String buttonText=m_addButtonText;
  if (m_onlyCategories) {
    buttonText=IDialogConstants.OK_LABEL;
  }
  m_addButton=createButton(parent,IDialogConstants.OK_ID,buttonText,true);
  m_addButton.addSelectionListener(new SelectionAdapter(){
    public void widgetSelected(    SelectionEvent e){
      setReturnCode(IDialogConstants.OK_ID);
      close();
    }
  }
);
  TreeViewer tv=m_testcaseTreeComposite.getTreeViewer();
  tv.addSelectionChangedListener(new ISelectionChangedListener(){
    public void selectionChanged(    SelectionChangedEvent e){
      if (e.getSelection() != null && !e.getSelection().isEmpty()) {
        m_lastSel=e.getSelection();
        m_addButton.setEnabled(true);
      }
    }
  }
);
  tv.addSelectionChangedListener(new ISelectionChangedListener(){
    public void selectionChanged(    SelectionChangedEvent event){
      m_addButton.setEnabled(checkDataValidityAndSetErrorMessage());
    }
  }
);
  tv.addDoubleClickListener(new IDoubleClickListener(){
    public void doubleClick(    DoubleClickEvent event){
      if (!m_addButton.getEnabled()) {
        return;
      }
      notifyListener();
      setReturnCode(IDialogConstants.OK_ID);
      close();
    }
  }
);
  if (m_preSelect != null) {
    tv.getControl().setFocus();
    tv.setSelection(new StructuredSelection(m_preSelect));
  }
  Button cancelButton=createButton(parent,CANCEL,Messages.TestCaseTableDialogCancel,false);
  cancelButton.addSelectionListener(new SelectionAdapter(){
    public void widgetSelected(    SelectionEvent e){
      setReturnCode(CANCEL);
      close();
    }
  }
);
  m_addButton.setEnabled(checkDataValidityAndSetErrorMessage());
}