@ -35,19 +35,20 @@ public class SearchFieldUI
private Image callIcon ;
/ * *
* The roll over icon of the call button .
* The roll over icon of the call button .
* /
private Image callRolloverIcon ;
/ * *
* The call button in the search field .
* Indicates if the mouse is currently over the call button .
* /
private SIPCommButton callButton ;
private boolean isCallMouseOver = false ;
/ * *
* Indicates if the mouse is currently over the call button .
* The call button tool tip string .
* /
private boolean isCallMouseOver = false ;
private final String callString
= GuiActivator . getResources ( ) . getI18NString ( "service.gui.CALL" ) ;
/ * *
* Creates a < tt > SIPCommTextFieldUI < / tt > .
@ -63,13 +64,6 @@ public SearchFieldUI()
callRolloverIcon = UtilActivator . getResources ( )
. getImage ( "service.gui.buttons.SEARCH_CALL_ROLLOVER_ICON" )
. getImage ( ) ;
callButton = new SIPCommButton ( callIcon , callRolloverIcon ) ;
callButton . setToolTipText ( GuiActivator . getResources ( )
. getI18NString ( "service.gui.CALL_ANY_NUMBER" ) ) ;
callButton . setSize ( callRolloverIcon . getWidth ( null ) ,
callRolloverIcon . getHeight ( null ) ) ;
}
/ * *
@ -123,7 +117,8 @@ protected void customPaintBackground(Graphics g)
dy = callRect . y ;
if ( c . getText ( ) ! = null
& & c . getText ( ) . length ( ) > 0 )
& & c . getText ( ) . length ( ) > 0
& & CallManager . getTelephonyProviders ( ) . size ( ) > 0 )
{
if ( isCallMouseOver )
g2 . drawImage ( callRolloverIcon , dx , dy , null ) ;
@ -151,7 +146,8 @@ protected Rectangle getVisibleEditorRect()
if ( ( rect . width > 0 ) & & ( rect . height > 0 ) )
{
rect . x + = searchIcon . getIconWidth ( ) + 8 ;
rect . width - = searchIcon . getIconWidth ( ) + callButton . getWidth ( ) + 15 ;
rect . width - = searchIcon . getIconWidth ( )
+ callRolloverIcon . getWidth ( null ) + 15 ;
return rect ;
}
return null ;
@ -237,17 +233,26 @@ private void updateCallIcon(MouseEvent evt)
if ( callButtonRect . contains ( x , y ) )
{
JTextComponent c = getComponent ( ) ;
String searchText = c . getText ( ) ;
if ( searchText = = null )
return ;
// Show a tool tip over the call button.
getComponent ( ) . setToolTipText ( callString + " " + searchText ) ;
ToolTipManager . sharedInstance ( ) . mouseEntered (
new MouseEvent ( getComponent ( ) , 0 , x , y ,
x , y , // X-Y of the mouse for the tool tip
0 , false ) ) ;
// Update the default cursor.
isCallMouseOver = true ;
getComponent ( ) . setCursor ( Cursor . getDefaultCursor ( ) ) ;
// Perform call action when the call button is clicked.
if ( evt . getID ( ) = = MouseEvent . MOUSE_CLICKED )
{
JTextComponent c = getComponent ( ) ;
String searchText = c . getText ( ) ;
if ( searchText = = null )
return ;
List < ProtocolProviderService > telephonyProviders
= CallManager . getTelephonyProviders ( ) ;
@ -271,7 +276,17 @@ else if (telephonyProviders.size() > 1)
}
}
else
{
// Remove the call button tool tip when the mouse exits the call
// button area.
getComponent ( ) . setToolTipText ( "" ) ;
ToolTipManager . sharedInstance ( ) . mouseExited (
new MouseEvent ( getComponent ( ) , 0 , x , y ,
x , y , // X-Y of the mouse for the tool tip
0 , false ) ) ;
isCallMouseOver = false ;
}
getComponent ( ) . repaint ( ) ;
}
@ -286,12 +301,12 @@ protected Rectangle getCallButtonRect()
Component c = getComponent ( ) ;
Rectangle rect = c . getBounds ( ) ;
int dx = getDeleteButtonRect ( ) . x - call Button. getWidth ( ) - 2 ;
int dy = ( rect . y + rect . height ) / 2 - call Button. getHeight ( ) / 2 ;
int dx = getDeleteButtonRect ( ) . x - call RolloverIcon. getWidth ( null ) - 2 ;
int dy = ( rect . y + rect . height ) / 2 - call RolloverIcon. getHeight ( null ) / 2 ;
return new Rectangle ( dx ,
dy ,
call Button. getWidth ( ) ,
call Button. getHeight ( ) ) ;
call RolloverIcon. getWidth ( null ) ,
call RolloverIcon. getHeight ( null ) ) ;
}
}