Program: 168132
Project: 168132
Buggy source:
@Override protected void createMasterPart(final IManagedForm managedForm,Composite parent){
  FormToolkit toolkit=managedForm.getToolkit();
  Section section=toolkit.createSection(parent,Section.DESCRIPTION | Section.TITLE_BAR);
  section.setText("String_Node_Str");
  Composite client=toolkit.createComposite(section,SWT.WRAP);
  GridLayout layout=new GridLayout();
  layout.numColumns=2;
  layout.marginWidth=2;
  layout.marginHeight=2;
  client.setLayout(layout);
  toolkit.paintBordersFor(client);
  final TreeViewer corpuses=new TreeViewer(client,SWT.BORDER);
  GridData gd=new GridData(GridData.FILL_BOTH);
  gd.heightHint=400;
  gd.widthHint=100;
  corpuses.getTree().setLayoutData(gd);
  Composite buttonComposite=new Composite(client,SWT.NONE);
  GridLayout buttonLayout=new GridLayout();
  buttonLayout.marginWidth=buttonLayout.marginHeight=0;
  buttonLayout.makeColumnsEqualWidth=true;
  buttonComposite.setLayout(buttonLayout);
  buttonComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL));
  Button addCorpus=toolkit.createButton(buttonComposite,"String_Node_Str",SWT.PUSH);
  GridDataFactory.fillDefaults().grab(false,false).span(1,1).applyTo(addCorpus);
  final Button addClass=toolkit.createButton(buttonComposite,"String_Node_Str",SWT.PUSH);
  GridDataFactory.fillDefaults().grab(false,false).span(1,1).applyTo(addClass);
  Button remove=toolkit.createButton(buttonComposite,"String_Node_Str",SWT.PUSH);
  GridDataFactory.fillDefaults().grab(false,false).span(1,1).applyTo(remove);
  section.setClient(client);
  final SectionPart spart=new SectionPart(section);
  managedForm.addPart(spart);
  corpuses.addSelectionChangedListener(new ISelectionChangedListener(){
    @Override public void selectionChanged(    SelectionChangedEvent event){
      managedForm.fireSelectionChanged(spart,event.getSelection());
      try {
        IStructuredSelection selection=(IStructuredSelection)event.getSelection();
        Object selectedObj=selection.getFirstElement();
        if (selectedObj instanceof ICorpus) {
          addClass.setEnabled(true);
        }
 else         if (selectedObj instanceof ICorpusClass) {
          addClass.setEnabled(false);
        }
      }
 catch (      Exception exp) {
      }
    }
  }
);
  corpuses.setContentProvider(new MasterContentProvider());
  corpuses.setLabelProvider(new MasterLabelProvider());
  for (  ICorpus corpus : corpusList)   ((Corpus)corpus).setViewer(corpuses);
  corpuses.setInput(corpusList);
  addCorpus.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      StringBuilder corpusTempName=new StringBuilder("String_Node_Str");
      corpusTempName.append(corpusList.size() + 1);
      Corpus c=new Corpus(new String(corpusTempName),DataType.PLAIN_TEXT,corpuses);
      c.addClass(new CorpusClass("String_Node_Str",ICorpusManagementConstants.DEFAULT_CLASSPATH,corpuses));
      ;
      corpusList.add(c);
      Object[] expandedItems=corpuses.getExpandedElements();
      corpuses.setInput(corpusList);
      corpuses.setExpandedElements(expandNewCorpus(expandedItems,c));
      corpuses.setSelection(new StructuredSelection(c),true);
    }
  }
);
  addClass.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      IStructuredSelection selection=(IStructuredSelection)corpuses.getSelection();
      try {
        ICorpus corpusSelected=(ICorpus)selection.getFirstElement();
        int corpusIndex=corpusList.indexOf(corpusSelected);
        StringBuilder classTempName=new StringBuilder("String_Node_Str");
        classTempName.append(corpusList.get(corpusIndex).getClasses().size() + 1);
        CorpusClass newClass=new CorpusClass(new String(classTempName),ICorpusManagementConstants.DEFAULT_CLASSPATH,corpuses);
        ((Corpus)corpusSelected).addClass(newClass);
        corpusList.set(corpusIndex,corpusSelected);
        corpuses.refresh();
        corpuses.setExpandedElements(expandNewCorpus(corpuses.getExpandedElements(),(Corpus)corpusList.get(corpusIndex)));
        corpuses.setSelection(new StructuredSelection(newClass),true);
      }
 catch (      Exception exp) {
      }
    }
  }
);
  remove.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      IStructuredSelection selection=(IStructuredSelection)corpuses.getSelection();
      try {
        Object selectedObj=selection.getFirstElement();
        if (selectedObj instanceof ICorpus) {
          ICorpus selectedCorpus=(ICorpus)selection.getFirstElement();
          corpusList.remove(selectedCorpus);
          ManageCorpora.removeCorpus((Corpus)selectedCorpus,true);
        }
 else         if (selectedObj instanceof ICorpusClass) {
          ITreeSelection classSelection=(ITreeSelection)selection;
          ICorpusClass selectedClass=(ICorpusClass)selection.getFirstElement();
          Corpus parentCorpus=(Corpus)classSelection.getPaths()[0].getParentPath().getLastSegment();
          parentCorpus.removeClass(selectedClass);
          ManageCorpora.removeCorpus(parentCorpus,false);
        }
        corpuses.refresh();
      }
 catch (      Exception exp) {
      }
    }
  }
);
}

Fixed version (ground truth):
@Override protected void createMasterPart(final IManagedForm managedForm,Composite parent){
  FormToolkit toolkit=managedForm.getToolkit();
  Section section=toolkit.createSection(parent,Section.DESCRIPTION | Section.TITLE_BAR);
  section.setText("String_Node_Str");
  Composite client=toolkit.createComposite(section,SWT.WRAP);
  GridLayout layout=new GridLayout();
  layout.numColumns=2;
  layout.marginWidth=2;
  layout.marginHeight=2;
  client.setLayout(layout);
  toolkit.paintBordersFor(client);
  final TreeViewer corpusViewer=new TreeViewer(client,SWT.BORDER);
  GridData gd=new GridData(GridData.FILL_BOTH);
  gd.heightHint=400;
  gd.widthHint=100;
  corpusViewer.getTree().setLayoutData(gd);
  Composite buttonComposite=new Composite(client,SWT.NONE);
  GridLayout buttonLayout=new GridLayout();
  buttonLayout.marginWidth=buttonLayout.marginHeight=0;
  buttonLayout.makeColumnsEqualWidth=true;
  buttonComposite.setLayout(buttonLayout);
  buttonComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL));
  Button addCorpus=toolkit.createButton(buttonComposite,"String_Node_Str",SWT.PUSH);
  GridDataFactory.fillDefaults().grab(false,false).span(1,1).applyTo(addCorpus);
  final Button addClass=toolkit.createButton(buttonComposite,"String_Node_Str",SWT.PUSH);
  GridDataFactory.fillDefaults().grab(false,false).span(1,1).applyTo(addClass);
  Button remove=toolkit.createButton(buttonComposite,"String_Node_Str",SWT.PUSH);
  GridDataFactory.fillDefaults().grab(false,false).span(1,1).applyTo(remove);
  section.setClient(client);
  final SectionPart spart=new SectionPart(section);
  managedForm.addPart(spart);
  corpusViewer.addSelectionChangedListener(new ISelectionChangedListener(){
    @Override public void selectionChanged(    SelectionChangedEvent event){
      managedForm.fireSelectionChanged(spart,event.getSelection());
      try {
        IStructuredSelection selection=(IStructuredSelection)event.getSelection();
        Object selectedObj=selection.getFirstElement();
        if (selectedObj instanceof ICorpus) {
          addClass.setEnabled(true);
        }
 else         if (selectedObj instanceof ICorpusClass) {
          addClass.setEnabled(false);
        }
      }
 catch (      Exception exp) {
      }
    }
  }
);
  corpusViewer.setContentProvider(new MasterContentProvider());
  corpusViewer.setLabelProvider(new MasterLabelProvider());
  for (  ICorpus corpus : corpusList) {
    ((Corpus)corpus).setViewer(corpusViewer);
    for (    ICorpusClass cc : corpus.getClasses()) {
      ((CorpusClass)cc).setViewer(corpusViewer);
    }
  }
  corpusViewer.setInput(corpusList);
  addCorpus.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      StringBuilder corpusTempName=new StringBuilder("String_Node_Str");
      corpusTempName.append(corpusList.size() + 1);
      Corpus c=new Corpus(new String(corpusTempName),DataType.PLAIN_TEXT,corpusViewer);
      c.addClass(new CorpusClass("String_Node_Str",ICorpusManagementConstants.DEFAULT_CLASSPATH,corpusViewer));
      ;
      corpusList.add(c);
      Object[] expandedItems=corpusViewer.getExpandedElements();
      corpusViewer.setInput(corpusList);
      corpusViewer.setExpandedElements(expandNewCorpus(expandedItems,c));
      corpusViewer.setSelection(new StructuredSelection(c),true);
    }
  }
);
  addClass.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      IStructuredSelection selection=(IStructuredSelection)corpusViewer.getSelection();
      try {
        ICorpus corpusSelected=(ICorpus)selection.getFirstElement();
        int corpusIndex=corpusList.indexOf(corpusSelected);
        StringBuilder classTempName=new StringBuilder("String_Node_Str");
        classTempName.append(corpusList.get(corpusIndex).getClasses().size() + 1);
        CorpusClass newClass=new CorpusClass(new String(classTempName),ICorpusManagementConstants.DEFAULT_CLASSPATH,corpusViewer);
        ((Corpus)corpusSelected).addClass(newClass);
        corpusList.set(corpusIndex,corpusSelected);
        corpusViewer.refresh();
        corpusViewer.setExpandedElements(expandNewCorpus(corpusViewer.getExpandedElements(),(Corpus)corpusList.get(corpusIndex)));
        corpusViewer.setSelection(new StructuredSelection(newClass),true);
      }
 catch (      Exception exp) {
      }
    }
  }
);
  remove.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      IStructuredSelection selection=(IStructuredSelection)corpusViewer.getSelection();
      try {
        Object selectedObj=selection.getFirstElement();
        if (selectedObj instanceof ICorpus) {
          ICorpus selectedCorpus=(ICorpus)selection.getFirstElement();
          corpusList.remove(selectedCorpus);
          ManageCorpora.removeCorpus((Corpus)selectedCorpus,true);
        }
 else         if (selectedObj instanceof ICorpusClass) {
          ITreeSelection classSelection=(ITreeSelection)selection;
          ICorpusClass selectedClass=(ICorpusClass)selection.getFirstElement();
          Corpus parentCorpus=(Corpus)classSelection.getPaths()[0].getParentPath().getLastSegment();
          parentCorpus.removeClass(selectedClass);
          ManageCorpora.removeCorpus(parentCorpus,false);
        }
        corpusViewer.refresh();
      }
 catch (      Exception exp) {
      }
    }
  }
);
}