Introduces the possibility to call any number one has typed in the search field (Issue # 816 Calling certain numbers/contacts that are not in the user list is possible only if the full address/name is typed).

cusax-fix
Yana Stamcheva 16 years ago
parent f06e3d7de6
commit 463184bc56

@ -176,6 +176,8 @@ service.gui.buttons.CHAT_ROOM_CONFIG=resources/images/impl/gui/buttons/chatRoomC
service.gui.buttons.CHAT_CALL=resources/images/impl/gui/buttons/chatCall.png
service.gui.buttons.CALL_HISTORY_BUTTON=resources/images/impl/gui/buttons/callHistoryButton.png
service.gui.buttons.CALL_HISTORY_BUTTON_PRESSED=resources/images/impl/gui/buttons/callHistoryButtonPressed.png
service.gui.buttons.SEARCH_CALL_ICON=resources/images/impl/gui/buttons/searchCallIcon.png
service.gui.buttons.SEARCH_CALL_ROLLOVER_ICON=resources/images/impl/gui/buttons/searchCallRolloverIcon.png
# Sound level icons
service.gui.soundlevel.SOUND_LEVEL_ACTIVE=resources/images/impl/gui/common/soundlevel/soundActive.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 625 B

@ -74,6 +74,7 @@ service.gui.BRB_MESSAGE=I'm gone right now, but I'll be back.
service.gui.BROWSE=Browse
service.gui.BUSY_MESSAGE=Sorry, I'm busy right now.
service.gui.CALL=Call
service.gui.CALL_ANY_NUMBER=Call any number you typed
service.gui.CALL_CONTACT=Call contact
service.gui.CALL_HISTORY_TOOL_TIP=Click here to show call history
service.gui.CALL_VIA=Call via:
@ -244,6 +245,7 @@ service.gui.LOGOFF_NOT_SUCCEEDED=An error occured while logging off with the fol
service.gui.ME=me
service.gui.MEMBER=member
service.gui.MISSED_CALLS_TOOL_TIP=Click here to see your missed calls
service.gui.MISSED_CALLS_MORE_TOOL_TIP= and {0} more
service.gui.MODERATOR=moderator
service.gui.MORE=See more
service.gui.MOVE=Move

@ -11,7 +11,6 @@
import net.java.sip.communicator.util.*;
import net.java.sip.communicator.util.swing.*;
import net.java.sip.communicator.util.swing.event.*;
import net.java.sip.communicator.util.swing.plaf.*;
/**
* The field shown on the top of the main window, which allows the user to
@ -46,7 +45,7 @@ public SearchField(MainFrame frame)
this.mainFrame = frame;
SearchTextFieldUI textFieldUI = new SearchTextFieldUI();
SearchFieldUI textFieldUI = new SearchFieldUI();
textFieldUI.setDeleteButtonEnabled(true);
this.setUI(textFieldUI);
this.setBorder(null);

@ -0,0 +1,297 @@
package net.java.sip.communicator.impl.gui.main.contactlist;
import java.awt.*;
import java.awt.event.*;
import java.util.List;
import javax.swing.*;
import javax.swing.text.*;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.main.call.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.*;
import net.java.sip.communicator.util.swing.*;
import net.java.sip.communicator.util.swing.plaf.*;
/**
* The <tt>SearchTextFieldUI</tt> is the one responsible for the search field
* look & feel. It draws a search icon inside the field and adjusts the bounds
* of the editor rectangle according to it.
*
* @author Yana Stamcheva
*/
public class SearchFieldUI
extends SIPCommTextFieldUI
{
/**
* The icon indicating that this is a search field.
*/
private ImageIcon searchIcon;
/**
* The default icon of the call button.
*/
private Image callIcon;
/**
* The rollover icon of the call button.
*/
private Image callRolloverIcon;
/**
* The call button in the search field.
*/
private SIPCommButton callButton;
/**
* Indicates if the mouse is currently over the call button.
*/
private boolean isCallMouseOver = false;
/**
* Creates a <tt>SIPCommTextFieldUI</tt>.
*/
public SearchFieldUI()
{
searchIcon = UtilActivator.getResources()
.getImage("service.gui.icons.SEARCH_ICON");
callIcon = UtilActivator.getResources()
.getImage("service.gui.buttons.SEARCH_CALL_ICON").getImage();
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));
}
/**
* Adds the custom mouse listeners defined in this class to the installed
* listeners.
*/
protected void installListeners()
{
super.installListeners();
getComponent().addMouseListener(
new TextFieldMouseListener());
getComponent().addMouseMotionListener(
new TextFieldMouseMotionListener());
}
/**
* Implements parent paintSafely method and enables antialiasing.
* @param g the <tt>Graphics</tt> object that notified us
*/
protected void paintSafely(Graphics g)
{
customPaintBackground(g);
super.paintSafely(g);
}
/**
* Paints the background of the associated component.
* @param g the <tt>Graphics</tt> object used for painting
*/
protected void customPaintBackground(Graphics g)
{
Graphics2D g2 = (Graphics2D) g.create();
try
{
AntialiasingManager.activateAntialiasing(g2);
super.customPaintBackground(g2);
JTextComponent c = this.getComponent();
int dy = (c.getY() + c.getHeight()) / 2
- searchIcon.getIconHeight()/2;
g2.drawImage(searchIcon.getImage(), c.getX(), dy + 1, null);
// Paint call button.
Rectangle callRect = getCallButtonRect();
int dx = callRect.x;
dy = callRect.y;
if (c.getText() != null
&& c.getText().length() > 0)
{
if (isCallMouseOver)
g2.drawImage(callRolloverIcon, dx, dy, null);
else
g2.drawImage(callIcon, dx, dy, null);
}
}
finally
{
g2.dispose();
}
}
/**
* If we are in the case of disabled delete button, we simply call the
* parent implementation of this method, otherwise we recalculate the editor
* rectangle in order to leave place for the delete button.
* @return the visible editor rectangle
*/
protected Rectangle getVisibleEditorRect()
{
Rectangle rect = super.getVisibleEditorRect();
if ((rect.width > 0) && (rect.height > 0))
{
rect.x += searchIcon.getIconWidth() + 8;
rect.width -= searchIcon.getIconWidth() + callButton.getWidth() + 15;
return rect;
}
return null;
}
/**
* The <tt>MouseListener</tt> that listens for mouse events in order to
* update the delete icon.
*/
protected class TextFieldMouseListener implements MouseListener
{
/**
* Updates the call button when the mouse was clicked.
* @param e the <tt>MouseEvent</tt> that notified us of the click
*/
public void mouseClicked(MouseEvent e)
{
updateCallIcon(e);
}
/**
* Updates the call button when the mouse is enters the component area.
* @param e the <tt>MouseEvent</tt> that notified us
*/
public void mouseEntered(MouseEvent e)
{
updateCallIcon(e);
}
/**
* Updates the call button when the mouse exits the component area.
* @param e the <tt>MouseEvent</tt> that notified us
*/
public void mouseExited(MouseEvent e)
{
updateCallIcon(e);
}
public void mousePressed(MouseEvent e) {}
public void mouseReleased(MouseEvent e) {}
}
/**
* The <tt>MouseMotionListener</tt> that listens for mouse events in order
* to update the delete icon.
*/
protected class TextFieldMouseMotionListener implements MouseMotionListener
{
/**
* Updates the delete icon when the mouse is dragged over.
* @param e the <tt>MouseEvent</tt> that notified us
*/
public void mouseDragged(MouseEvent e)
{
updateCallIcon(e);
}
/**
* Updates the delete icon when the mouse is moved over.
* @param e the <tt>MouseEvent</tt> that notified us
*/
public void mouseMoved(MouseEvent e)
{
updateCallIcon(e);
}
}
/**
* Updates the delete icon, changes the cursor and deletes the content of
* the associated text component when the mouse is pressed over the delete
* icon.
*
* @param evt the mouse event that has prompted us to update the delete
* icon.
*/
private void updateCallIcon(MouseEvent evt)
{
int x = evt.getX();
int y = evt.getY();
Rectangle callButtonRect = getCallButtonRect();
if (callButtonRect.contains(x, y))
{
isCallMouseOver = true;
getComponent().setCursor(Cursor.getDefaultCursor());
if (evt.getID() == MouseEvent.MOUSE_CLICKED)
{
JTextComponent c = getComponent();
String searchText = c.getText();
if (searchText == null)
return;
List<ProtocolProviderService> telephonyProviders
= CallManager.getTelephonyProviders();
if (telephonyProviders.size() == 1)
{
CallManager.createCall(
telephonyProviders.get(0), searchText);
}
else if (telephonyProviders.size() > 1)
{
ChooseCallAccountPopupMenu chooseAccountDialog
= new ChooseCallAccountPopupMenu(
c,
searchText,
telephonyProviders);
chooseAccountDialog
.setLocation(getCallButtonRect().getLocation());
chooseAccountDialog.showPopupMenu();
}
}
}
else
isCallMouseOver = false;
getComponent().repaint();
}
/**
* Calculates the call button rectangle.
*
* @return the call button rectangle
*/
protected Rectangle getCallButtonRect()
{
Component c = getComponent();
Rectangle rect = c.getBounds();
int dx = getDeleteButtonRect().x - callButton.getWidth() - 2;
int dy = (rect.y + rect.height) / 2 - callButton.getHeight()/2;
return new Rectangle( dx,
dy,
callButton.getWidth(),
callButton.getHeight());
}
}

@ -22,12 +22,24 @@
public class SIPCommTextFieldUI
extends MetalTextFieldUI
{
private boolean mouseOver = false;
/**
* Indicates if the mouse is currently over the delete button.
*/
protected boolean isDeleteMouseOver = false;
private static int BUTTON_GAP = 5;
/**
* The gap between the delete button and the text in the field.
*/
protected static int BUTTON_GAP = 5;
/**
* The image of the delete text button.
*/
private Image deleteButtonImg;
/**
* The rollover image of the delete text button.
*/
private Image deleteButtonRolloverImg;
/**
@ -36,7 +48,10 @@ public class SIPCommTextFieldUI
*/
private boolean isDeleteButtonEnabled = false;
private SIPCommButton deleteButton;
/**
* The delete text button shown on the right of the field.
*/
protected SIPCommButton deleteButton;
/**
* Creates a <tt>SIPCommTextFieldUI</tt>.
@ -109,16 +124,15 @@ protected void customPaintBackground(Graphics g)
g2.setColor(Color.WHITE);
g2.fillRoundRect(1, 1, c.getWidth() - 2, c.getHeight() - 2, 20, 20);
int dx = c.getX() + c.getWidth()
- deleteButton.getWidth() - BUTTON_GAP - 5;
int dy = (c.getY() + c.getHeight()) / 2
- deleteButton.getHeight()/2;
Rectangle deleteButtonRect = getDeleteButtonRect();
int dx = deleteButtonRect.x;
int dy = deleteButtonRect.y;
if (c.getText() != null
&& c.getText().length() > 0
&& isDeleteButtonEnabled)
{
if (mouseOver)
if (isDeleteMouseOver)
g2.drawImage(deleteButtonRolloverImg, dx, dy, null);
else
g2.drawImage(deleteButtonImg, dx, dy, null);
@ -153,18 +167,14 @@ protected void updateDeleteIcon(MouseEvent evt)
if (deleteRect.contains(x, y))
{
mouseOver = true;
isDeleteMouseOver = true;
getComponent().setCursor(Cursor.getDefaultCursor());
if (evt.getID() == MouseEvent.MOUSE_CLICKED)
getComponent().setText("");
}
else
{
mouseOver = false;
getComponent().setCursor(
Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
}
isDeleteMouseOver = false;
getComponent().repaint();
}
@ -176,9 +186,11 @@ protected void updateDeleteIcon(MouseEvent evt)
*/
protected Rectangle getDeleteButtonRect()
{
Rectangle rect = getVisibleEditorRect();
JTextComponent c = getComponent();
int dx = rect.x + rect.width;
Rectangle rect = c.getBounds();
int dx = rect.x + rect.width - deleteButton.getWidth() - BUTTON_GAP - 5;
int dy = (rect.y + rect.height) / 2 - deleteButton.getHeight()/2;
return new Rectangle( dx,
@ -232,6 +244,7 @@ protected class TextFieldMouseListener implements MouseListener
public void mouseClicked(MouseEvent e)
{
updateDeleteIcon(e);
updateCursor(e);
}
/**
@ -241,6 +254,7 @@ public void mouseClicked(MouseEvent e)
public void mouseEntered(MouseEvent e)
{
updateDeleteIcon(e);
updateCursor(e);
}
/**
@ -250,6 +264,7 @@ public void mouseEntered(MouseEvent e)
public void mouseExited(MouseEvent e)
{
updateDeleteIcon(e);
updateCursor(e);
}
public void mousePressed(MouseEvent e) {}
@ -270,6 +285,7 @@ protected class TextFieldMouseMotionListener implements MouseMotionListener
public void mouseDragged(MouseEvent e)
{
updateDeleteIcon(e);
updateCursor(e);
}
/**
@ -279,6 +295,16 @@ public void mouseDragged(MouseEvent e)
public void mouseMoved(MouseEvent e)
{
updateDeleteIcon(e);
updateCursor(e);
}
}
private void updateCursor(MouseEvent mouseEvent)
{
if (getVisibleEditorRect().contains(mouseEvent.getPoint()))
{
getComponent().setCursor(
Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
}
}
}

@ -1,86 +0,0 @@
package net.java.sip.communicator.util.swing.plaf;
import java.awt.*;
import javax.swing.*;
import javax.swing.text.*;
import net.java.sip.communicator.util.*;
import net.java.sip.communicator.util.swing.*;
/**
* The <tt>SearchTextFieldUI</tt> is the one responsible for the search field
* look & feel. It draws a search icon inside the field and adjusts the bounds
* of the editor rectangle according to it.
*
* @author Yana Stamcheva
*/
public class SearchTextFieldUI
extends SIPCommTextFieldUI
{
private ImageIcon searchImg;
/**
* Creates a <tt>SIPCommTextFieldUI</tt>.
*/
public SearchTextFieldUI()
{
searchImg = UtilActivator.getResources()
.getImage("service.gui.icons.SEARCH_ICON");
}
/**
* Implements parent paintSafely method and enables antialiasing.
* @param g the <tt>Graphics</tt> object that notified us
*/
protected void paintSafely(Graphics g)
{
customPaintBackground(g);
super.paintSafely(g);
}
/**
* Paints the background of the associated component.
* @param g the <tt>Graphics</tt> object used for painting
*/
protected void customPaintBackground(Graphics g)
{
Graphics2D g2 = (Graphics2D) g.create();
try
{
AntialiasingManager.activateAntialiasing(g2);
super.customPaintBackground(g2);
JTextComponent c = this.getComponent();
int dy = (c.getY() + c.getHeight()) / 2
- searchImg.getIconHeight()/2;
g2.drawImage(searchImg.getImage(), c.getX(), dy + 1, null);
}
finally
{
g2.dispose();
}
}
/**
* If we are in the case of disabled delete button, we simply call the
* parent implementation of this method, otherwise we recalculate the editor
* rectangle in order to leave place for the delete button.
* @return the visible editor rectangle
*/
protected Rectangle getVisibleEditorRect()
{
Rectangle rect = super.getVisibleEditorRect();
if ((rect.width > 0) && (rect.height > 0))
{
rect.x += searchImg.getIconWidth() + 8;
rect.width -= searchImg.getIconWidth() + 15;
return rect;
}
return null;
}
}
Loading…
Cancel
Save