Program: 140194
Project: 140194
Buggy source:
public static void createTable(Composite parent,ChartWithData inputObject,final Analysis analysis){
  TableViewer tbViewer=new TableViewer(parent,SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
  final Table table=tbViewer.getTable();
  table.setHeaderVisible(true);
  table.setLinesVisible(true);
  GridData gd=new GridData();
  gd.heightHint=220;
  gd.widthHint=500;
  gd.verticalAlignment=SWT.BEGINNING;
  table.setLayoutData(gd);
  String[] names=null;
  Integer[] widths=null;
  final EIndicatorChartType chartTableType=inputObject.getChartType();
switch (chartTableType) {
case FREQUENCE_STATISTICS:
    names=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"};
  widths=new Integer[]{200,150,150};
break;
case MODE_INDICATOR:
names=new String[]{"String_Node_Str"};
widths=new Integer[]{500};
break;
case SQL_PATTERN_MATCHING:
case PATTERN_MATCHING:
names=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
widths=new Integer[]{200,75,75,75,75};
break;
case SIMPLE_STATISTICS:
names=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"};
widths=new Integer[]{200,150,150};
break;
case TEXT_STATISTICS:
names=new String[]{"String_Node_Str","String_Node_Str"};
widths=new Integer[]{200,300};
break;
case SUMMARY_STATISTICS:
names=new String[]{"String_Node_Str","String_Node_Str"};
widths=new Integer[]{200,300};
break;
default :
}
createTableColumnStructure(names,widths,table);
tbViewer.setLabelProvider(ChartTableProviderFactory.createLabelProvider(chartTableType));
tbViewer.setContentProvider(ChartTableProviderFactory.createContentProvider(chartTableType));
tbViewer.setInput(inputObject);
tbViewer.addSelectionChangedListener(new ISelectionChangedListener(){
public void selectionChanged(SelectionChangedEvent event){
StructuredSelection selection=(StructuredSelection)event.getSelection();
ChartDataEntity dataEntity=(ChartDataEntity)selection.getFirstElement();
final Indicator indicator=dataEntity.getIndicator();
Menu menu=new Menu(table.getShell(),SWT.POP_UP);
table.setMenu(menu);
MenuItemEntity[] itemEntities=ChartTableMenuGenerator.generate(chartTableType,analysis,dataEntity);
for (final MenuItemEntity itemEntity : itemEntities) {
MenuItem item=new MenuItem(menu,SWT.PUSH);
item.setText(itemEntity.getLabel());
item.setImage(itemEntity.getIcon());
item.addListener(SWT.Selection,new Listener(){
public void handleEvent(Event event){
viewRecordInDataExplorer(analysis,indicator,itemEntity.getQuery());
}
}
);
}
menu.setVisible(true);
}
}
);
addTooltipOnTableItem(table);
}

Fixed version (ground truth):
public static void createTable(Composite parent,ChartWithData inputObject,final Analysis analysis){
  TableViewer tbViewer=new TableViewer(parent,SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
  final Table table=tbViewer.getTable();
  table.setHeaderVisible(true);
  table.setLinesVisible(true);
  GridData gd=new GridData();
  gd.heightHint=220;
  gd.widthHint=500;
  gd.verticalAlignment=SWT.BEGINNING;
  table.setLayoutData(gd);
  String[] names=null;
  Integer[] widths=null;
  final EIndicatorChartType chartTableType=inputObject.getChartType();
switch (chartTableType) {
case FREQUENCE_STATISTICS:
case LOW_FREQUENCE_STATISTICS:
    names=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"};
  widths=new Integer[]{200,150,150};
break;
case MODE_INDICATOR:
names=new String[]{"String_Node_Str"};
widths=new Integer[]{500};
break;
case SQL_PATTERN_MATCHING:
case PATTERN_MATCHING:
names=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
widths=new Integer[]{200,75,75,75,75};
break;
case SIMPLE_STATISTICS:
names=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"};
widths=new Integer[]{200,150,150};
break;
case TEXT_STATISTICS:
names=new String[]{"String_Node_Str","String_Node_Str"};
widths=new Integer[]{200,300};
break;
case SUMMARY_STATISTICS:
names=new String[]{"String_Node_Str","String_Node_Str"};
widths=new Integer[]{200,300};
break;
default :
}
createTableColumnStructure(names,widths,table);
tbViewer.setLabelProvider(ChartTableProviderFactory.createLabelProvider(chartTableType));
tbViewer.setContentProvider(ChartTableProviderFactory.createContentProvider(chartTableType));
tbViewer.setInput(inputObject);
tbViewer.addSelectionChangedListener(new ISelectionChangedListener(){
public void selectionChanged(SelectionChangedEvent event){
StructuredSelection selection=(StructuredSelection)event.getSelection();
ChartDataEntity dataEntity=(ChartDataEntity)selection.getFirstElement();
final Indicator indicator=dataEntity.getIndicator();
Menu menu=new Menu(table.getShell(),SWT.POP_UP);
table.setMenu(menu);
MenuItemEntity[] itemEntities=ChartTableMenuGenerator.generate(chartTableType,analysis,dataEntity);
for (final MenuItemEntity itemEntity : itemEntities) {
MenuItem item=new MenuItem(menu,SWT.PUSH);
item.setText(itemEntity.getLabel());
item.setImage(itemEntity.getIcon());
item.addListener(SWT.Selection,new Listener(){
public void handleEvent(Event event){
viewRecordInDataExplorer(analysis,indicator,itemEntity.getQuery());
}
}
);
}
menu.setVisible(true);
}
}
);
addTooltipOnTableItem(table);
}