Program: 92243
Project: 92243
Buggy source:
/** 
 * Callback for the mouse-over tooltip
 * @param control The control object to use
 */
public void activateHoverHelp(final Control control){
  control.addMouseListener(new MouseAdapter(){
    @Override public void mouseDown(    MouseEvent e){
      if (_tipShell.isVisible()) {
        _tipShell.setVisible(false);
      }
    }
  }
);
  control.addMouseMoveListener(new MouseMoveListener(){
    @Override public void mouseMove(    MouseEvent e){
      if (_tipShell.isVisible()) {
        _tipShell.setVisible(false);
      }
    }
  }
);
  control.addMouseTrackListener(new MouseTrackAdapter(){
    @Override public void mouseExit(    MouseEvent e){
      if (_tipShell.isVisible()) {
        _tipShell.setVisible(false);
      }
    }
    private void addItem(    String name,    String value){
      TableItem line=new TableItem(_tipTable,SWT.NONE);
      line.setText(0,name);
      line.setText(1,value);
    }
    private void fillValues(    Point pt,    TimeGraphControl threadStates,    ITimeGraphEntry entry){
      if (entry == null) {
        return;
      }
      if (entry.hasTimeEvents()) {
        ITimeEvent threadEvent=Utils.findEvent(entry,threadStates.getTimeAtX(pt.x),2);
        ITimeEvent nextEvent=Utils.findEvent(entry,threadStates.getTimeAtX(pt.x),1);
        addItem(_utilImp.getStateTypeName(),entry.getName());
        if (threadEvent == null) {
          return;
        }
        String state=_utilImp.getEventName(threadEvent);
        if (state != null) {
          addItem(Messages.TmfTimeTipHandler_TRACE_STATE,state);
        }
        Map<String,String> eventAddOns=_utilImp.getEventHoverToolTipInfo(threadEvent);
        if (eventAddOns != null) {
          for (Iterator<String> iter=eventAddOns.keySet().iterator(); iter.hasNext(); ) {
            String message=iter.next();
            addItem(message,eventAddOns.get(message));
          }
        }
        long eventStartTime=-1;
        long eventDuration=-1;
        long eventEndTime=-1;
        eventStartTime=threadEvent.getTime();
        eventDuration=threadEvent.getDuration();
        if (eventDuration < 0 && nextEvent != null) {
          eventEndTime=nextEvent.getTime();
          eventDuration=eventEndTime - eventStartTime;
        }
 else {
          eventEndTime=eventStartTime + eventDuration;
        }
        Resolution res=Resolution.NANOSEC;
        if (_timeDataProvider.isCalendarFormat()) {
          addItem(Messages.TmfTimeTipHandler_TRACE_DATE,eventStartTime > -1 ? Utils.formatDate(eventStartTime) : "String_Node_Str");
          if (eventDuration > 0) {
            addItem(Messages.TmfTimeTipHandler_TRACE_START_TIME,eventStartTime > -1 ? Utils.formatTime(eventStartTime,TimeFormat.ABSOLUTE,res) : "String_Node_Str");
            addItem(Messages.TmfTimeTipHandler_TRACE_STOP_TIME,eventEndTime > -1 ? Utils.formatTime(eventEndTime,TimeFormat.ABSOLUTE,res) : "String_Node_Str");
          }
 else {
            addItem(Messages.TmfTimeTipHandler_TRACE_EVENT_TIME,eventStartTime > -1 ? Utils.formatTime(eventStartTime,TimeFormat.ABSOLUTE,res) : "String_Node_Str");
          }
        }
 else {
          if (eventDuration > 0) {
            addItem(Messages.TmfTimeTipHandler_TRACE_START_TIME,eventStartTime > -1 ? Utils.formatTime(eventStartTime,TimeFormat.RELATIVE,res) : "String_Node_Str");
            addItem(Messages.TmfTimeTipHandler_TRACE_STOP_TIME,eventEndTime > -1 ? Utils.formatTime(eventEndTime,TimeFormat.RELATIVE,res) : "String_Node_Str");
          }
 else {
            addItem(Messages.TmfTimeTipHandler_TRACE_EVENT_TIME,eventStartTime > -1 ? Utils.formatTime(eventStartTime,TimeFormat.RELATIVE,res) : "String_Node_Str");
          }
        }
        if (eventDuration > 0) {
          addItem(Messages.TmfTimeTipHandler_DURATION,eventDuration > -1 ? Utils.formatTime(eventDuration,TimeFormat.RELATIVE,res) : "String_Node_Str");
        }
      }
    }
    @Override public void mouseHover(    MouseEvent event){
      Point pt=new Point(event.x,event.y);
      TimeGraphControl threadStates=(TimeGraphControl)event.widget;
      ITimeGraphEntry entry=threadStates.getEntry(pt);
      _tipTable.remove(0,_tipTable.getItemCount() - 1);
      fillValues(pt,threadStates,entry);
      if (_tipTable.getItemCount() == 0) {
        return;
      }
      _tipTable.getColumn(0).pack();
      _tipTable.getColumn(1).pack();
      _tipShell.pack();
      _tipPosition=control.toDisplay(pt);
      _tipShell.pack();
      setHoverLocation(_tipShell,_tipPosition);
      _tipShell.setVisible(true);
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Callback for the mouse-over tooltip
 * @param control The control object to use
 */
public void activateHoverHelp(final Control control){
  control.addMouseListener(new MouseAdapter(){
    @Override public void mouseDown(    MouseEvent e){
      if (_tipShell != null && !_tipShell.isDisposed()) {
        _tipShell.dispose();
      }
    }
  }
);
  control.addMouseMoveListener(new MouseMoveListener(){
    @Override public void mouseMove(    MouseEvent e){
      if (_tipShell != null && !_tipShell.isDisposed()) {
        _tipShell.dispose();
      }
    }
  }
);
  control.addMouseTrackListener(new MouseTrackAdapter(){
    @Override public void mouseExit(    MouseEvent e){
      if (_tipShell != null && !_tipShell.isDisposed()) {
        Point pt=control.toDisplay(e.x,e.y);
        if (!_tipShell.getBounds().contains(pt)) {
          _tipShell.dispose();
        }
      }
    }
    private void addItem(    String name,    String value){
      TableItem line=new TableItem(_tipTable,SWT.NONE);
      line.setText(0,name);
      line.setText(1,value);
    }
    private void fillValues(    Point pt,    TimeGraphControl timeGraphControl,    ITimeGraphEntry entry){
      if (entry == null) {
        return;
      }
      if (entry.hasTimeEvents()) {
        long currPixelTime=timeGraphControl.getTimeAtX(pt.x);
        long nextPixelTime=timeGraphControl.getTimeAtX(pt.x + 1);
        if (nextPixelTime == currPixelTime) {
          nextPixelTime++;
        }
        ITimeEvent currEvent=Utils.findEvent(entry,currPixelTime,0);
        ITimeEvent nextEvent=Utils.findEvent(entry,currPixelTime,1);
        if (currEvent == null || currEvent.getTime() < currPixelTime) {
          if (nextEvent != null && nextEvent.getTime() < nextPixelTime) {
            currEvent=nextEvent;
          }
        }
        addItem(_utilImp.getStateTypeName(),entry.getName());
        if (currEvent == null) {
          return;
        }
        String state=_utilImp.getEventName(currEvent);
        if (state != null) {
          addItem(Messages.TmfTimeTipHandler_TRACE_STATE,state);
        }
        Map<String,String> eventAddOns=_utilImp.getEventHoverToolTipInfo(currEvent);
        if (eventAddOns != null) {
          for (Iterator<String> iter=eventAddOns.keySet().iterator(); iter.hasNext(); ) {
            String message=iter.next();
            addItem(message,eventAddOns.get(message));
          }
        }
        long eventStartTime=-1;
        long eventDuration=-1;
        long eventEndTime=-1;
        eventStartTime=currEvent.getTime();
        eventDuration=currEvent.getDuration();
        if (eventDuration < 0 && nextEvent != null) {
          eventEndTime=nextEvent.getTime();
          eventDuration=eventEndTime - eventStartTime;
        }
 else {
          eventEndTime=eventStartTime + eventDuration;
        }
        Resolution res=Resolution.NANOSEC;
        if (_timeDataProvider.isCalendarFormat()) {
          addItem(Messages.TmfTimeTipHandler_TRACE_DATE,eventStartTime > -1 ? Utils.formatDate(eventStartTime) : "String_Node_Str");
          if (eventDuration > 0) {
            addItem(Messages.TmfTimeTipHandler_TRACE_START_TIME,eventStartTime > -1 ? Utils.formatTime(eventStartTime,TimeFormat.ABSOLUTE,res) : "String_Node_Str");
            addItem(Messages.TmfTimeTipHandler_TRACE_STOP_TIME,eventEndTime > -1 ? Utils.formatTime(eventEndTime,TimeFormat.ABSOLUTE,res) : "String_Node_Str");
          }
 else {
            addItem(Messages.TmfTimeTipHandler_TRACE_EVENT_TIME,eventStartTime > -1 ? Utils.formatTime(eventStartTime,TimeFormat.ABSOLUTE,res) : "String_Node_Str");
          }
        }
 else {
          if (eventDuration > 0) {
            addItem(Messages.TmfTimeTipHandler_TRACE_START_TIME,eventStartTime > -1 ? Utils.formatTime(eventStartTime,TimeFormat.RELATIVE,res) : "String_Node_Str");
            addItem(Messages.TmfTimeTipHandler_TRACE_STOP_TIME,eventEndTime > -1 ? Utils.formatTime(eventEndTime,TimeFormat.RELATIVE,res) : "String_Node_Str");
          }
 else {
            addItem(Messages.TmfTimeTipHandler_TRACE_EVENT_TIME,eventStartTime > -1 ? Utils.formatTime(eventStartTime,TimeFormat.RELATIVE,res) : "String_Node_Str");
          }
        }
        if (eventDuration > 0) {
          addItem(Messages.TmfTimeTipHandler_DURATION,eventDuration > -1 ? Utils.formatTime(eventDuration,TimeFormat.RELATIVE,res) : "String_Node_Str");
        }
      }
    }
    @Override public void mouseHover(    MouseEvent event){
      Point pt=new Point(event.x,event.y);
      TimeGraphControl timeGraphControl=(TimeGraphControl)event.widget;
      createTooltipShell(timeGraphControl.getShell());
      ITimeGraphEntry entry=timeGraphControl.getEntry(pt);
      _tipTable.remove(0,_tipTable.getItemCount() - 1);
      fillValues(pt,timeGraphControl,entry);
      if (_tipTable.getItemCount() == 0) {
        return;
      }
      _tipTable.getColumn(0).pack();
      _tipTable.getColumn(1).pack();
      _tipShell.pack();
      _tipPosition=control.toDisplay(pt);
      _tipShell.pack();
      setHoverLocation(_tipShell,_tipPosition);
      _tipShell.setVisible(true);
    }
  }
);
}