Fixes incorrect painting of the call peer menu (and chat Smileys menu) on Windows.

cusax-fix
Yana Stamcheva 16 years ago
parent 7282d6fc03
commit 1e1c6b5a95

@ -185,4 +185,4 @@ service.gui.CALL_PEER_NAME_BACKGROUND=A6D6FF
service.gui.CALL_MEMBER_NAME_BACKGROUND=BDFFA3 service.gui.CALL_MEMBER_NAME_BACKGROUND=BDFFA3
# Conference call local user title panel background color. # Conference call local user title panel background color.
service.gui.CALL_LOCAL_USER_BACKGROUND=398bcc service.gui.CALL_LOCAL_USER_BACKGROUND=A6D6FF

@ -26,8 +26,8 @@
* *
* @author Yana Stamcheva * @author Yana Stamcheva
*/ */
public class CallPeerActionMenuBar public class CallPeerMenu
extends SIPCommMenuBar extends SIPCommMenu
implements CallPeerListener, implements CallPeerListener,
PropertyChangeListener PropertyChangeListener
{ {
@ -52,24 +52,20 @@ public class CallPeerActionMenuBar
* <tt>callPeer</tt>. * <tt>callPeer</tt>.
* @param peer the <tt>CallPeer</tt> associated with the contained menus * @param peer the <tt>CallPeer</tt> associated with the contained menus
*/ */
public CallPeerActionMenuBar(CallPeer peer) public CallPeerMenu(CallPeer peer)
{ {
this.callPeer = peer; this.callPeer = peer;
SIPCommMenu menu = new SIPCommMenu();
menu.setPreferredSize(new Dimension(20, 20));
this.setOpaque(false); this.setOpaque(false);
menu.setOpaque(false); this.setPreferredSize(new Dimension(20, 20));
// Should explicitly remove any border in order to align correctly the // Should explicitly remove any border in order to align correctly the
// icon. // icon.
menu.setBorder(BorderFactory.createEmptyBorder()); this.setBorder(BorderFactory.createEmptyBorder());
menu.setIcon(new ImageIcon(ImageLoader this.setIcon(new ImageIcon(ImageLoader
.getImage(ImageLoader.CALL_PEER_TOOLS))); .getImage(ImageLoader.CALL_PEER_TOOLS)));
menu.setIconTextGap(0); this.setIconTextGap(0);
menu.addItem( this.addItem(
GuiActivator.getResources().getI18NString("service.gui.HANG_UP"), GuiActivator.getResources().getI18NString("service.gui.HANG_UP"),
null, null,
new ActionListener() new ActionListener()
@ -83,10 +79,10 @@ public void actionPerformed(ActionEvent e)
initHoldMenuItem(); initHoldMenuItem();
initMuteMenuItem(); initMuteMenuItem();
menu.add(holdMenuItem); this.add(holdMenuItem);
menu.add(muteMenuItem); this.add(muteMenuItem);
menu.addItem( this.addItem(
GuiActivator.getResources().getI18NString( GuiActivator.getResources().getI18NString(
"service.gui.TRANSFER_BUTTON_TOOL_TIP"), "service.gui.TRANSFER_BUTTON_TOOL_TIP"),
null, null,
@ -98,8 +94,6 @@ public void actionPerformed(ActionEvent e)
} }
}); });
this.add(menu);
// Add the call peer listener that would notify us for call peer state // Add the call peer listener that would notify us for call peer state
// changes. We'll be using these notifications in order to update the // changes. We'll be using these notifications in order to update the
// hold menu item state. // hold menu item state.

@ -42,9 +42,9 @@ public class ConferencePeerPanel
private CallPeer callPeer; private CallPeer callPeer;
/** /**
* The action menu available for all call peers. * The tools menu available for each peer.
*/ */
private CallPeerActionMenuBar actionMenuBar; private CallPeerMenu callPeerMenu;
/** /**
* The label showing whether the voice has been set to mute. * The label showing whether the voice has been set to mute.
@ -101,7 +101,9 @@ public ConferencePeerPanel( CallDialog callDialog,
{ {
this.callDialog = callDialog; this.callDialog = callDialog;
this.setPeerName(protocolProvider.getAccountID().getUserID()); this.setPeerName(protocolProvider.getAccountID().getUserID()
+ " (" + GuiActivator.getResources()
.getI18NString("service.gui.ACCOUNT_ME").toLowerCase() + ")");
this.setTitleBackground( this.setTitleBackground(
new Color(GuiActivator.getResources().getColor( new Color(GuiActivator.getResources().getColor(
@ -128,8 +130,12 @@ public ConferencePeerPanel(CallDialog callDialog, CallPeer callPeer)
// We initialize the status bar for call peers only. // We initialize the status bar for call peers only.
this.initStatusBar(callPeer); this.initStatusBar(callPeer);
actionMenuBar = new CallPeerActionMenuBar(callPeer); callPeerMenu = new CallPeerMenu(callPeer);
this.addToNameBar(actionMenuBar);
SIPCommMenuBar menuBar = new SIPCommMenuBar();
menuBar.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));
menuBar.add(callPeerMenu);
this.addToNameBar(menuBar);
this.setTitleBackground( this.setTitleBackground(
new Color(GuiActivator.getResources().getColor( new Color(GuiActivator.getResources().getColor(

@ -13,7 +13,6 @@
import javax.swing.event.*; import javax.swing.event.*;
import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.lookandfeel.*; import net.java.sip.communicator.impl.gui.lookandfeel.*;
import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.util.swing.*; import net.java.sip.communicator.util.swing.*;
@ -26,15 +25,13 @@
* @author Lubomir Marinov * @author Lubomir Marinov
*/ */
public class SmileysSelectorBox public class SmileysSelectorBox
extends SIPCommMenuBar extends SIPCommMenu
implements ActionListener, implements ActionListener,
MouseListener, MouseListener,
PopupMenuListener PopupMenuListener
{ {
private final ChatWritePanel chatWritePanel; private final ChatWritePanel chatWritePanel;
private final SIPCommMenu selectorBox = new SIPCommMenu();
private final JLabel smileyTextLabel = new JLabel(); private final JLabel smileyTextLabel = new JLabel();
private final JLabel smileyDescriptionLabel = new JLabel(); private final JLabel smileyDescriptionLabel = new JLabel();
@ -49,15 +46,13 @@ public SmileysSelectorBox(ChatWritePanel writePanel)
this.chatWritePanel = writePanel; this.chatWritePanel = writePanel;
this.setOpaque(false); this.setOpaque(false);
this.selectorBox.setOpaque(false);
// Should explicitly remove any border in order to align correctly the // Should explicitly remove any border in order to align correctly the
// icon. // icon.
this.selectorBox.setBorder(BorderFactory.createEmptyBorder()); this.setBorder(BorderFactory.createEmptyBorder());
this.selectorBox.setIcon(new ImageIcon(ImageLoader this.setIcon(new ImageIcon(ImageLoader
.getImage(ImageLoader.SMILIES_ICON))); .getImage(ImageLoader.SMILIES_ICON)));
JPopupMenu popupMenu = this.selectorBox.getPopupMenu(); JPopupMenu popupMenu = this.getPopupMenu();
popupMenu.setLayout(new GridBagLayout()); popupMenu.setLayout(new GridBagLayout());
popupMenu.setBackground(Color.WHITE); popupMenu.setBackground(Color.WHITE);
@ -67,8 +62,6 @@ public SmileysSelectorBox(ChatWritePanel writePanel)
* they are not always necessary. * they are not always necessary.
*/ */
popupMenu.addPopupMenuListener(this); popupMenu.addPopupMenuListener(this);
this.add(selectorBox);
} }
/** /**
@ -97,7 +90,7 @@ private Dimension calculateGridDimensions(int itemsCount)
*/ */
public void open() public void open()
{ {
this.selectorBox.doClick(); this.doClick();
} }
/** /**
@ -107,12 +100,13 @@ public void open()
*/ */
public boolean isMenuSelected() public boolean isMenuSelected()
{ {
return selectorBox.isPopupMenuVisible(); return isPopupMenuVisible();
} }
/** /**
* Writes the symbol corresponding to a chosen smiley icon to the write * Writes the symbol corresponding to a chosen smiley icon to the write
* message area at the end of the current text. * message area at the end of the current text.
* @param e the <tt>ActionEvent</tt> that notified us
*/ */
public void actionPerformed(ActionEvent e) public void actionPerformed(ActionEvent e)
{ {
@ -126,34 +120,12 @@ public void actionPerformed(ActionEvent e)
clearMouseOverEffects(smileyItem); clearMouseOverEffects(smileyItem);
} }
/**
* Sets the given text to this smiley selector box. The given text will be
* position by default on the bottom of the icon.
*
* @param text the text to be added to this selector box.
*/
public void setText(String text)
{
this.selectorBox.setText(text);
this.selectorBox.setFont(getFont().deriveFont(Font.BOLD, 10f));
this.selectorBox.setVerticalTextPosition(SwingConstants.BOTTOM);
this.selectorBox.setHorizontalTextPosition(SwingConstants.CENTER);
this.selectorBox.setForeground(new Color(GuiActivator.getResources()
.getColor("service.gui.CHAT_MENU_FOREGROUND")));
}
public void paintComponent(Graphics g)
{
}
/** /**
* A custom menu item, which paints round border over selection. * A custom menu item, which paints round border over selection.
*/ */
private static class SmileyMenuItem private static class SmileyMenuItem
extends JMenuItem extends JMenuItem
{ {
/** /**
* The <tt>Smiley</tt> depicted by this instance. * The <tt>Smiley</tt> depicted by this instance.
*/ */
@ -177,6 +149,7 @@ public SmileyMenuItem(Smiley smiley)
/** /**
* Changes the static image of the underlying smiley with a dynamic one. * Changes the static image of the underlying smiley with a dynamic one.
* Also shows the description and smiley string in the description area. * Also shows the description and smiley string in the description area.
* @param e the <tt>MouseEvent</tt> that notified us
*/ */
public void mouseEntered(MouseEvent e) public void mouseEntered(MouseEvent e)
{ {
@ -193,6 +166,7 @@ public void mouseEntered(MouseEvent e)
/** /**
* Clears all mouse over effects when the mouse has exited the smiley area. * Clears all mouse over effects when the mouse has exited the smiley area.
* @param e the <tt>MouseEvent</tt> that notified us
*/ */
public void mouseExited(MouseEvent e) public void mouseExited(MouseEvent e)
{ {
@ -201,17 +175,11 @@ public void mouseExited(MouseEvent e)
this.clearMouseOverEffects(smileyItem); this.clearMouseOverEffects(smileyItem);
} }
public void mouseClicked(MouseEvent e) public void mouseClicked(MouseEvent e) {}
{
}
public void mousePressed(MouseEvent e) public void mousePressed(MouseEvent e) {}
{
}
public void mouseReleased(MouseEvent e) public void mouseReleased(MouseEvent e) {}
{
}
/** /**
* Clears all mouse over effects for the given smiley item. This method * Clears all mouse over effects for the given smiley item. This method
@ -230,27 +198,26 @@ private void clearMouseOverEffects(SmileyMenuItem smileyItem)
smileyDescriptionLabel.setText(""); smileyDescriptionLabel.setText("");
} }
/* /**
* Implements PopupMenuListener#popupMenuCanceled(PopupMenuEvent). Does * Implements PopupMenuListener#popupMenuCanceled(PopupMenuEvent). Does
* nothing. * nothing.
* @param e the <tt>PopupMenuEvent</tt>
*/ */
public void popupMenuCanceled(PopupMenuEvent e) public void popupMenuCanceled(PopupMenuEvent e) {}
{
}
/* /**
* Implements * Implements
* PopupMenuListener#popupMenuWillBecomeInvisible(PopupMenuEvent). Does * PopupMenuListener#popupMenuWillBecomeInvisible(PopupMenuEvent). Does
* nothing. * nothing.
* @param e the <tt>PopupMenuEvent</tt>
*/ */
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {}
{
}
/* /**
* Implements PopupMenuListener#popupMenuWillBecomeVisible(PopupMenuEvent). * Implements PopupMenuListener#popupMenuWillBecomeVisible(PopupMenuEvent).
* Loads the smileys and creates the UI to represent them when they are * Loads the smileys and creates the UI to represent them when they are
* first necessary. * first necessary.
* @param e the <tt>PopupMenuEvent</tt> that notified us
*/ */
public void popupMenuWillBecomeVisible(PopupMenuEvent e) public void popupMenuWillBecomeVisible(PopupMenuEvent e)
{ {

@ -47,6 +47,7 @@ public class EditTextToolBar
/** /**
* Creates an instance and constructs the <tt>EditTextToolBar</tt>. * Creates an instance and constructs the <tt>EditTextToolBar</tt>.
* @param writePanel the panel containing the chat write area
*/ */
public EditTextToolBar(ChatWritePanel writePanel) public EditTextToolBar(ChatWritePanel writePanel)
{ {
@ -79,7 +80,11 @@ public void actionPerformed(ActionEvent event)
this.smileysBox.setToolTipText(GuiActivator.getResources() this.smileysBox.setToolTipText(GuiActivator.getResources()
.getI18NString("service.gui.INSERT_SMILEY") + " Ctrl-M"); .getI18NString("service.gui.INSERT_SMILEY") + " Ctrl-M");
this.add(smileysBox); SIPCommMenuBar smileyMenuBar = new SIPCommMenuBar();
smileyMenuBar.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));
smileyMenuBar.add(smileysBox);
this.add(smileyMenuBar);
} }
/** /**

@ -19,34 +19,67 @@
import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.util.swing.*; import net.java.sip.communicator.util.swing.*;
/**
* The panel shown on the top of the contact list. It contains user name,
* current status menu and the avatar of the user.
*
* @author Yana Stamcheva
*/
public class AccountStatusPanel public class AccountStatusPanel
extends TransparentPanel extends TransparentPanel
implements RegistrationStateChangeListener implements RegistrationStateChangeListener
{ {
/**
* The desired height of the avatar.
*/
private static final int AVATAR_ICON_HEIGHT = 45; private static final int AVATAR_ICON_HEIGHT = 45;
/**
* The desired width of the avatar.
*/
private static final int AVATAR_ICON_WIDTH = 45; private static final int AVATAR_ICON_WIDTH = 45;
/**
* The image object storing the avatar.
*/
private final FramedImage accountImageLabel; private final FramedImage accountImageLabel;
/**
* The label showing the name of the user.
*/
private final JLabel accountNameLabel private final JLabel accountNameLabel
= new JLabel( = new JLabel(
GuiActivator GuiActivator
.getResources().getI18NString("service.gui.ACCOUNT_ME")); .getResources().getI18NString("service.gui.ACCOUNT_ME"));
/**
* The background color property.
*/
private final Color bgColor private final Color bgColor
= new Color( = new Color(GuiActivator.getResources()
GuiActivator
.getResources()
.getColor("service.gui.LOGO_BAR_BACKGROUND")); .getColor("service.gui.LOGO_BAR_BACKGROUND"));
/**
* The background image property.
*/
private final Image logoBgImage private final Image logoBgImage
= ImageLoader.getImage(ImageLoader.WINDOW_TITLE_BAR); = ImageLoader.getImage(ImageLoader.WINDOW_TITLE_BAR);
/**
* The combo box containing status menu.
*/
private final GlobalStatusSelectorBox statusComboBox; private final GlobalStatusSelectorBox statusComboBox;
/**
* TexturePaint used to paint background image.
*/
private final TexturePaint texture; private final TexturePaint texture;
/**
* Creates an instance of <tt>AccountStatusPanel</tt> by specifying the
* main window, where this panel is added.
* @param mainFrame the main window, where this panel is added
*/
public AccountStatusPanel(MainFrame mainFrame) public AccountStatusPanel(MainFrame mainFrame)
{ {
super(new BorderLayout(10, 0)); super(new BorderLayout(10, 0));
@ -96,6 +129,12 @@ public AccountStatusPanel(MainFrame mainFrame)
bgImage.getHeight(null))); bgImage.getHeight(null)));
} }
/**
* Adds the account given by <tt>protocolProvider</tt> in the contained
* status combo box.
* @param protocolProvider the <tt>ProtocolProviderService</tt>
* corresponding to the account to add
*/
public void addAccount(ProtocolProviderService protocolProvider) public void addAccount(ProtocolProviderService protocolProvider)
{ {
statusComboBox.addAccount(protocolProvider); statusComboBox.addAccount(protocolProvider);
@ -103,6 +142,12 @@ public void addAccount(ProtocolProviderService protocolProvider)
protocolProvider.addRegistrationStateChangeListener(this); protocolProvider.addRegistrationStateChangeListener(this);
} }
/**
* Removes the account given by <tt>protocolProvider</tt> from the contained
* status combo box.
* @param protocolProvider the <tt>ProtocolProviderService</tt>
* corresponding to the account to remove
*/
public void removeAccount(ProtocolProviderService protocolProvider) public void removeAccount(ProtocolProviderService protocolProvider)
{ {
statusComboBox.removeAccount(protocolProvider); statusComboBox.removeAccount(protocolProvider);
@ -110,28 +155,63 @@ public void removeAccount(ProtocolProviderService protocolProvider)
protocolProvider.removeRegistrationStateChangeListener(this); protocolProvider.removeRegistrationStateChangeListener(this);
} }
/**
* Checks if an account corresponding to the given <tt>protocolProvider</tt>
* is contained in the contained status combo box.
* @param protocolProvider the <tt>ProtocolProviderService</tt>
* corresponding to the account to check for
* @return <tt>true</tt> to indicate that an account corresponding to the
* given <tt>protocolProvider</tt> is contained in the status box,
* <tt>false</tt> - otherwise
*/
public boolean containsAccount(ProtocolProviderService protocolProvider) public boolean containsAccount(ProtocolProviderService protocolProvider)
{ {
return statusComboBox.containsAccount(protocolProvider); return statusComboBox.containsAccount(protocolProvider);
} }
/**
* Returns the last used presence status for the given
* <tt>protocolProvider</tt>.
* @param protocolProvider the <tt>ProtocolProviderService</tt>
* corresponding to the account we're looking for
* @return the last used presence status for the given
* <tt>protocolProvider</tt>
*/
public Object getLastPresenceStatus( public Object getLastPresenceStatus(
ProtocolProviderService protocolProvider) ProtocolProviderService protocolProvider)
{ {
return statusComboBox.getLastPresenceStatus(protocolProvider); return statusComboBox.getLastPresenceStatus(protocolProvider);
} }
/**
* Returns the last used status for the given <tt>protocolProvider</tt>
* as a String.
* @param protocolProvider the <tt>ProtocolProviderService</tt>
* corresponding to the account we're looking for
* @return a String representation of the last used status for the given
* <tt>protocolProvider</tt>
*/
public String getLastStatusString(ProtocolProviderService protocolProvider) public String getLastStatusString(ProtocolProviderService protocolProvider)
{ {
return statusComboBox.getLastStatusString(protocolProvider); return statusComboBox.getLastStatusString(protocolProvider);
} }
/**
* Updates the current status of the <tt>protocolProvider</tt> with the
* <tt>newStatus</tt>.
* @param protocolProvider the <tt>ProtocolProviderService</tt> to update
* @param newStatus the new status to set
*/
public void updateStatus( ProtocolProviderService protocolProvider, public void updateStatus( ProtocolProviderService protocolProvider,
PresenceStatus newStatus) PresenceStatus newStatus)
{ {
statusComboBox.updateStatus(protocolProvider, newStatus); statusComboBox.updateStatus(protocolProvider, newStatus);
} }
/**
* Updates the current status of the <tt>protocolProvider</tt>.
* @param protocolProvider the <tt>ProtocolProviderService</tt> to update
*/
public void updateStatus( ProtocolProviderService protocolProvider) public void updateStatus( ProtocolProviderService protocolProvider)
{ {
statusComboBox.updateStatus(protocolProvider); statusComboBox.updateStatus(protocolProvider);
@ -227,6 +307,10 @@ else if (lastName != null)
} }
} }
/**
* Paints this component.
* @param g the <tt>Graphics</tt> object used for painting
*/
public void paintComponent(Graphics g) public void paintComponent(Graphics g)
{ {
super.paintComponent(g); super.paintComponent(g);

@ -42,33 +42,67 @@ public class GlobalStatusSelectorBox
extends StatusSelectorMenu extends StatusSelectorMenu
implements ActionListener implements ActionListener
{ {
/**
* The indent of the image.
*/
private static final int IMAGE_INDENT = 10; private static final int IMAGE_INDENT = 10;
/**
* The arrow icon shown on the right of the status and indicating that
* this is a menu.
*/
private final Image arrowImage private final Image arrowImage
= ImageLoader.getImage(ImageLoader.DOWN_ARROW_ICON); = ImageLoader.getImage(ImageLoader.DOWN_ARROW_ICON);
private final Logger logger = Logger.getLogger(GlobalStatusSelectorBox.class); /**
* The object used for logging.
*/
private final Logger logger
= Logger.getLogger(GlobalStatusSelectorBox.class);
/**
* Mapping of <tt>ProtocolProviderService</tt> and corresponding
* <tt>StatusSelectorMenu</tt>.
*/
private final Map<ProtocolProviderService, StatusSelectorMenu> accountMenus private final Map<ProtocolProviderService, StatusSelectorMenu> accountMenus
= new Hashtable<ProtocolProviderService, StatusSelectorMenu>(); = new Hashtable<ProtocolProviderService, StatusSelectorMenu>();
/**
* The main application window.
*/
private final MainFrame mainFrame; private final MainFrame mainFrame;
// private ImageIcon dndIcon = new ImageIcon( // private ImageIcon dndIcon = new ImageIcon(
// ImageLoader.getImage(ImageLoader.USER_DND_ICON)); // ImageLoader.getImage(ImageLoader.USER_DND_ICON));
/**
* The item corresponding to the online status.
*/
private final JMenuItem onlineItem; private final JMenuItem onlineItem;
/**
* The item corresponding to the offline status.
*/
private final JMenuItem offlineItem; private final JMenuItem offlineItem;
/**
* The item corresponding to the away status.
*/
private final JMenuItem awayItem; private final JMenuItem awayItem;
// private JMenuItem dndItem = new JMenuItem( // private JMenuItem dndItem = new JMenuItem(
// GuiActivator.getResources().getI18NString("service.gui.DND_STATUS").getText(), // GuiActivator.getResources().getI18NString("service.gui.DND_STATUS")
// .getText(),
// dndIcon); // dndIcon);
/**
* The item corresponding to the free for chat status.
*/
private final JMenuItem ffcItem; private final JMenuItem ffcItem;
/**
* The width of the text.
*/
private int textWidth = 0; private int textWidth = 0;
/** /**
@ -119,6 +153,14 @@ public GlobalStatusSelectorBox(MainFrame mainFrame)
computeTextWidth(); computeTextWidth();
} }
/**
* Creates a menu item with the given <tt>textKey</tt>, <tt>iconID</tt> and
* <tt>name</tt>.
* @param textKey the text of the item
* @param iconID the icon of the item
* @param name the name of the item
* @return the created <tt>JMenuItem</tt>
*/
private JMenuItem createMenuItem( private JMenuItem createMenuItem(
String textKey, String textKey,
ImageID iconID, ImageID iconID,
@ -137,6 +179,11 @@ private JMenuItem createMenuItem(
return menuItem; return menuItem;
} }
/**
* Adds a status menu for the account given by <tt>protocolProvider</tt>.
* @param protocolProvider the <tt>ProtocolProviderService</tt>, for which
* to add a status menu
*/
public void addAccount(ProtocolProviderService protocolProvider) public void addAccount(ProtocolProviderService protocolProvider)
{ {
boolean isHidden boolean isHidden
@ -161,6 +208,12 @@ public void addAccount(ProtocolProviderService protocolProvider)
this.accountMenus.put(protocolProvider, statusSelectorMenu); this.accountMenus.put(protocolProvider, statusSelectorMenu);
} }
/**
* Removes the status menu corresponding to the account given by
* <tt>protocolProvider</tt>.
* @param protocolProvider the <tt>ProtocolProviderService</tt>, which
* menu to remove
*/
public void removeAccount(ProtocolProviderService protocolProvider) public void removeAccount(ProtocolProviderService protocolProvider)
{ {
StatusSelectorMenu statusSelectorMenu StatusSelectorMenu statusSelectorMenu
@ -170,14 +223,23 @@ public void removeAccount(ProtocolProviderService protocolProvider)
this.accountMenus.remove(protocolProvider); this.accountMenus.remove(protocolProvider);
} }
/**
* Checks if a menu for the given <tt>protocolProvider</tt> exists.
* @param protocolProvider the <tt>ProtocolProviderService</tt> to check
* @return <tt>true</tt> to indicate that a status menu for the given
* <tt>protocolProvider</tt> already exists, otherwise returns
* <tt>false</tt>
*/
public boolean containsAccount(ProtocolProviderService protocolProvider) public boolean containsAccount(ProtocolProviderService protocolProvider)
{ {
return accountMenus.containsKey(protocolProvider); return accountMenus.containsKey(protocolProvider);
} }
/** /**
* Returns TRUE if there are selected status selector boxes, otherwise * Returns <tt>true</tt> if there are selected status selector boxes,
* returns FALSE. * otherwise returns <tt>false</tt>.
* @return <tt>true</tt> if there are selected status selector boxes,
* otherwise returns <tt>false</tt>
*/ */
public boolean hasSelectedMenus() public boolean hasSelectedMenus()
{ {
@ -190,13 +252,15 @@ public boolean hasSelectedMenus()
/** /**
* Handles the <tt>ActionEvent</tt> triggered when one of the items * Handles the <tt>ActionEvent</tt> triggered when one of the items
* in the list is selected. * in the list is selected.
* @param e the <tt>ActionEvent</tt> that notified us
*/ */
public void actionPerformed(ActionEvent e) public void actionPerformed(ActionEvent e)
{ {
JMenuItem menuItem = (JMenuItem) e.getSource(); JMenuItem menuItem = (JMenuItem) e.getSource();
String itemName = menuItem.getName(); String itemName = menuItem.getName();
Iterator<ProtocolProviderService> pProviders = mainFrame.getProtocolProviders(); Iterator<ProtocolProviderService> pProviders
= mainFrame.getProtocolProviders();
while (pProviders.hasNext()) while (pProviders.hasNext())
{ {
@ -376,9 +440,12 @@ else if (itemName.equals(Constants.AWAY_STATUS))
if (status != null) if (status != null)
{ {
if (currentStatus.getStatus() < PresenceStatus.AVAILABLE_THRESHOLD if (currentStatus.getStatus()
&& currentStatus.getStatus() >= PresenceStatus.ONLINE_THRESHOLD < PresenceStatus.AVAILABLE_THRESHOLD
&& currentStatus.getStatus() > status.getStatus()) && currentStatus.getStatus()
>= PresenceStatus.ONLINE_THRESHOLD
&& currentStatus.getStatus()
> status.getStatus())
{ {
status = currentStatus; status = currentStatus;
} }
@ -397,6 +464,11 @@ else if (itemName.equals(Constants.AWAY_STATUS))
} }
} }
/**
* Updates the status of the given <tt>protocolProvider</tt>.
* @param protocolProvider the <tt>ProtocolProviderService</tt>
* corresponding to the menu to update
*/
public void updateStatus(ProtocolProviderService protocolProvider) public void updateStatus(ProtocolProviderService protocolProvider)
{ {
StatusSelectorMenu accountMenu = accountMenus.get(protocolProvider); StatusSelectorMenu accountMenu = accountMenus.get(protocolProvider);
@ -435,6 +507,13 @@ public void updateStatus(ProtocolProviderService protocolProvider)
this.updateGlobalStatus(); this.updateGlobalStatus();
} }
/**
* Updates the status of the given <tt>protocolProvider</tt> with the given
* <tt>presenceStatus</tt>.
* @param protocolProvider the <tt>ProtocolProviderService</tt>
* corresponding to the menu to update
* @param presenceStatus the new status to set
*/
public void updateStatus(ProtocolProviderService protocolProvider, public void updateStatus(ProtocolProviderService protocolProvider,
PresenceStatus presenceStatus) PresenceStatus presenceStatus)
{ {
@ -540,9 +619,10 @@ private class PublishPresenceStatusThread
private OperationSetPresence presence; private OperationSetPresence presence;
/** /**
* * Publishes the given <tt>status</tt> through the given
* @param presence * <tt>presence</tt> operation set.
* @param status * @param presence the operation set through which we publish the status
* @param status the status to publish
*/ */
public PublishPresenceStatusThread( OperationSetPresence presence, public PublishPresenceStatusThread( OperationSetPresence presence,
PresenceStatus status) PresenceStatus status)
@ -717,6 +797,7 @@ public String getLastStatusString(ProtocolProviderService protocolProvider)
/** /**
* Overwrites the <tt>paintComponent(Graphics g)</tt> method in order to * Overwrites the <tt>paintComponent(Graphics g)</tt> method in order to
* provide a new look and the mouse moves over this component. * provide a new look and the mouse moves over this component.
* @param g the <tt>Graphics</tt> object used for painting
*/ */
public void paintComponent(Graphics g) public void paintComponent(Graphics g)
{ {
@ -743,7 +824,8 @@ public void paintComponent(Graphics g)
} }
/** /**
* Computes the width of the text in pixels in order to position the arrow during its painting. * Computes the width of the text in pixels in order to position the arrow
* during its painting.
*/ */
private void computeTextWidth() private void computeTextWidth()
{ {

Loading…
Cancel
Save