Program: 140136
Project: 140136
Buggy source:
public static void createTable(Composite parent,ChartWithData inputObject,final Analysis analysis){
  final TableViewer tbViewer=new TableViewer(parent,SWT.BORDER | 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:
case PATTERN_FREQUENCE_STATISTICS:
case PATTERN_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.getTable().addMouseListener(new MouseAdapter(){
@Override public void mouseDown(MouseEvent e){
if (e.button == 3) {
StructuredSelection selection=(StructuredSelection)tbViewer.getSelection();
ChartDataEntity dataEntity=(ChartDataEntity)selection.getFirstElement();
final Indicator indicator=dataEntity.getIndicator();
if (indicator != null) {
Menu menu=new Menu(table.getShell(),SWT.POP_UP);
table.setMenu(menu);
int createPatternFlag=0;
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());
}
}
);
if (createPatternFlag == 0) {
MenuItem itemCreatePatt=new MenuItem(menu,SWT.PUSH);
final PatternTransformer pattTransformer=new PatternTransformer(DbmsLanguageFactory.createDbmsLanguage(analysis));
itemCreatePatt.setText("String_Node_Str");
itemCreatePatt.addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent e){
createPattern(analysis,itemEntity,pattTransformer);
}
}
);
}
}
createPatternFlag++;
menu.setVisible(true);
}
}
}
}
);
addTooltipOnTableItem(table);
}

Fixed version (ground truth):
public static void createTable(Composite parent,ChartWithData inputObject,final Analysis analysis){
  final TableViewer tbViewer=new TableViewer(parent,SWT.BORDER | 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:
case PATTERN_FREQUENCE_STATISTICS:
case PATTERN_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.getTable().addMouseListener(new MouseAdapter(){
@Override public void mouseDown(MouseEvent e){
if (e.button == 3) {
StructuredSelection selection=(StructuredSelection)tbViewer.getSelection();
ChartDataEntity dataEntity=(ChartDataEntity)selection.getFirstElement();
final Indicator indicator=dataEntity.getIndicator();
if (indicator != null) {
Menu menu=new Menu(table.getShell(),SWT.POP_UP);
table.setMenu(menu);
int createPatternFlag=0;
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());
}
}
);
if ((indicator.getName().trim().equals("String_Node_Str") || indicator.getName().trim().equals("String_Node_Str")) && createPatternFlag == 0) {
MenuItem itemCreatePatt=new MenuItem(menu,SWT.PUSH);
final PatternTransformer pattTransformer=new PatternTransformer(DbmsLanguageFactory.createDbmsLanguage(analysis));
itemCreatePatt.setText("String_Node_Str");
itemCreatePatt.addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent e){
createPattern(analysis,itemEntity,pattTransformer);
}
}
);
}
}
createPatternFlag++;
menu.setVisible(true);
}
}
}
}
);
addTooltipOnTableItem(table);
}