Program: 140141
Project: 140141
Buggy source:
private static void addTooltipOnTableItem(final Table table){
  table.setToolTipText("String_Node_Str");
  final Shell shell=new Shell(PlatformUI.getWorkbench().getDisplay());
  shell.setLayout(new FillLayout());
  final Listener labelListener=new Listener(){
    public void handleEvent(    Event event){
      Label label=(Label)event.widget;
      Shell shell=label.getShell();
switch (event.type) {
case SWT.MouseDown:
        Event e=new Event();
      e.item=(TableItem)label.getData("String_Node_Str");
    table.setSelection(new TableItem[]{(TableItem)e.item});
  table.notifyListeners(SWT.Selection,e);
case SWT.MouseExit:
shell.dispose();
break;
default :
break;
}
}
}
;
Listener tableListener=new Listener(){
Shell tip=null;
Label label=null;
public void handleEvent(Event event){
switch (event.type) {
case SWT.Dispose:
case SWT.KeyDown:
case SWT.MouseMove:
if (tip == null) {
break;
}
tip.dispose();
tip=null;
label=null;
break;
case SWT.MouseHover:
TableItem item=table.getItem(new Point(event.x,event.y));
if (item != null) {
ChartDataEntity entity=(ChartDataEntity)item.getData();
String rangeAsString=entity.getRangeAsString();
if (rangeAsString != null) {
showTip(item,rangeAsString);
}
}
default :
break;
}
}
private void showTip(TableItem item,String msg){
if (tip != null && !tip.isDisposed()) {
tip.dispose();
}
tip=new Shell(shell,SWT.ON_TOP | SWT.TOOL);
tip.setLayout(new FillLayout());
label=new Label(tip,SWT.NONE);
label.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
label.setData("String_Node_Str",item);
label.setText(msg);
label.addListener(SWT.MouseExit,labelListener);
label.addListener(SWT.MouseDown,labelListener);
Point size=tip.computeSize(SWT.DEFAULT,SWT.DEFAULT);
Rectangle rect=item.getBounds(1);
Point pt=table.toDisplay(rect.x,rect.y);
tip.setBounds(pt.x + 10,pt.y + 10,size.x,size.y);
tip.setVisible(true);
}
}
;
table.addListener(SWT.Dispose,tableListener);
table.addListener(SWT.KeyDown,tableListener);
table.addListener(SWT.MouseMove,tableListener);
table.addListener(SWT.MouseHover,tableListener);
}

Fixed version (ground truth):
private static void addTooltipOnTableItem(final Table table){
  table.setToolTipText("String_Node_Str");
  final Shell shell=new Shell(PlatformUI.getWorkbench().getDisplay());
  shell.setLayout(new FillLayout());
  final Listener labelListener=new Listener(){
    public void handleEvent(    Event event){
      Label label=(Label)event.widget;
      Shell shell=label.getShell();
switch (event.type) {
case SWT.MouseDown:
        Event e=new Event();
      e.item=(TableItem)label.getData("String_Node_Str");
    table.setSelection(new TableItem[]{(TableItem)e.item});
  table.notifyListeners(SWT.Selection,e);
case SWT.MouseExit:
shell.dispose();
break;
default :
break;
}
}
}
;
Listener tableListener=new Listener(){
Shell tip=null;
Label label=null;
public void handleEvent(Event event){
switch (event.type) {
case SWT.Dispose:
case SWT.KeyDown:
case SWT.MouseMove:
if (tip == null) {
break;
}
tip.dispose();
tip=null;
label=null;
break;
case SWT.MouseHover:
TableItem item=table.getItem(new Point(event.x,event.y));
if (item != null) {
ChartDataEntity entity=(ChartDataEntity)item.getData();
String rangeAsString=entity.getRangeAsString();
if (rangeAsString != null) {
showTip(item,rangeAsString);
}
}
default :
break;
}
}
private void showTip(TableItem item,String msg){
if (tip != null && !tip.isDisposed()) {
tip.dispose();
}
tip=new Shell(shell,SWT.ON_TOP | SWT.TOOL);
tip.setLayout(new FillLayout());
label=new Label(tip,SWT.NONE);
label.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
label.setData("String_Node_Str",item);
label.setText(msg);
label.addListener(SWT.MouseExit,labelListener);
label.addListener(SWT.MouseDown,labelListener);
Point size=tip.computeSize(SWT.DEFAULT,SWT.DEFAULT);
Rectangle rect=item.getBounds(1);
Point pt=table.toDisplay(rect.x,rect.y);
tip.setBounds(pt.x + 10,pt.y + 18,size.x,size.y);
tip.setVisible(true);
}
}
;
table.addListener(SWT.Dispose,tableListener);
table.addListener(SWT.KeyDown,tableListener);
table.addListener(SWT.MouseMove,tableListener);
table.addListener(SWT.MouseHover,tableListener);
}