// Creating listeners for component if they aren't created yet
if ( !timers.containsKey ( component ) || !adapters.containsKey ( component ) )
{
// Tooltip pop timer
final WebTimer showTips = new WebTimer ( "TooltipManager.displayTimer", delay );
showTips.addActionListener ( new ActionListener ()
{
@Override
public void actionPerformed ( final ActionEvent e )
{
final Window wa = SwingUtils.getWindowAncestor ( component );
if ( wa != null && wa.isActive () )
{
showTooltips ( component, false );
}
}
} );
showTips.setRepeats ( false );
timers.put ( component, showTips );
// Show/hide listener
final MouseAdapter mouseAdapter = new MouseAdapter ()
{
@Override
public void mouseEntered ( final MouseEvent e )
{
// Component ancestor window
final Window window = SwingUtils.getWindowAncestor ( component );
// Starting show timer if needed
if ( window.isShowing () && window.isActive () )
{
showTips.start ();
}
}
@Override
public void mouseExited ( final MouseEvent e )
{
cancelTooltips ();
}
@Override
public void mousePressed ( final MouseEvent e )
{
cancelTooltips ();
}
@Override
public void mouseReleased ( final MouseEvent e )
{
cancelTooltips ();
}
private void cancelTooltips ()
{
// Hiding component tooltips
showTips.stop ();
hideTooltips ( component );
}
};
component.addMouseListener ( mouseAdapter );
adapters.put ( component, mouseAdapter );