diff --git a/resources/colors/colors.properties b/resources/colors/colors.properties index e377f2a85..765e307e6 100644 --- a/resources/colors/colors.properties +++ b/resources/colors/colors.properties @@ -185,4 +185,4 @@ service.gui.CALL_PEER_NAME_BACKGROUND=A6D6FF service.gui.CALL_MEMBER_NAME_BACKGROUND=BDFFA3 # Conference call local user title panel background color. -service.gui.CALL_LOCAL_USER_BACKGROUND=398bcc +service.gui.CALL_LOCAL_USER_BACKGROUND=A6D6FF diff --git a/src/net/java/sip/communicator/impl/gui/main/call/conference/CallPeerActionMenuBar.java b/src/net/java/sip/communicator/impl/gui/main/call/conference/CallPeerMenu.java similarity index 92% rename from src/net/java/sip/communicator/impl/gui/main/call/conference/CallPeerActionMenuBar.java rename to src/net/java/sip/communicator/impl/gui/main/call/conference/CallPeerMenu.java index b3602c1cc..8b41fb8c0 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/conference/CallPeerActionMenuBar.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/conference/CallPeerMenu.java @@ -26,8 +26,8 @@ * * @author Yana Stamcheva */ -public class CallPeerActionMenuBar - extends SIPCommMenuBar +public class CallPeerMenu + extends SIPCommMenu implements CallPeerListener, PropertyChangeListener { @@ -52,24 +52,20 @@ public class CallPeerActionMenuBar * callPeer. * @param peer the CallPeer associated with the contained menus */ - public CallPeerActionMenuBar(CallPeer peer) + public CallPeerMenu(CallPeer peer) { this.callPeer = peer; - SIPCommMenu menu = new SIPCommMenu(); - - menu.setPreferredSize(new Dimension(20, 20)); - this.setOpaque(false); - menu.setOpaque(false); + this.setPreferredSize(new Dimension(20, 20)); // Should explicitly remove any border in order to align correctly the // icon. - menu.setBorder(BorderFactory.createEmptyBorder()); - menu.setIcon(new ImageIcon(ImageLoader + this.setBorder(BorderFactory.createEmptyBorder()); + this.setIcon(new ImageIcon(ImageLoader .getImage(ImageLoader.CALL_PEER_TOOLS))); - menu.setIconTextGap(0); - menu.addItem( + this.setIconTextGap(0); + this.addItem( GuiActivator.getResources().getI18NString("service.gui.HANG_UP"), null, new ActionListener() @@ -83,10 +79,10 @@ public void actionPerformed(ActionEvent e) initHoldMenuItem(); initMuteMenuItem(); - menu.add(holdMenuItem); - menu.add(muteMenuItem); + this.add(holdMenuItem); + this.add(muteMenuItem); - menu.addItem( + this.addItem( GuiActivator.getResources().getI18NString( "service.gui.TRANSFER_BUTTON_TOOL_TIP"), 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 // changes. We'll be using these notifications in order to update the // hold menu item state. diff --git a/src/net/java/sip/communicator/impl/gui/main/call/conference/ConferencePeerPanel.java b/src/net/java/sip/communicator/impl/gui/main/call/conference/ConferencePeerPanel.java index 911b9ee0c..e03487e3a 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/conference/ConferencePeerPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/conference/ConferencePeerPanel.java @@ -42,9 +42,9 @@ public class ConferencePeerPanel 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. @@ -101,7 +101,9 @@ public ConferencePeerPanel( 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( new Color(GuiActivator.getResources().getColor( @@ -128,8 +130,12 @@ public ConferencePeerPanel(CallDialog callDialog, CallPeer callPeer) // We initialize the status bar for call peers only. this.initStatusBar(callPeer); - actionMenuBar = new CallPeerActionMenuBar(callPeer); - this.addToNameBar(actionMenuBar); + callPeerMenu = new CallPeerMenu(callPeer); + + SIPCommMenuBar menuBar = new SIPCommMenuBar(); + menuBar.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); + menuBar.add(callPeerMenu); + this.addToNameBar(menuBar); this.setTitleBackground( new Color(GuiActivator.getResources().getColor( diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/SmileysSelectorBox.java b/src/net/java/sip/communicator/impl/gui/main/chat/SmileysSelectorBox.java index e35e2b348..179ae8561 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/SmileysSelectorBox.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/SmileysSelectorBox.java @@ -13,7 +13,6 @@ import javax.swing.event.*; 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.utils.*; import net.java.sip.communicator.util.swing.*; @@ -26,15 +25,13 @@ * @author Lubomir Marinov */ public class SmileysSelectorBox - extends SIPCommMenuBar + extends SIPCommMenu implements ActionListener, MouseListener, PopupMenuListener { private final ChatWritePanel chatWritePanel; - private final SIPCommMenu selectorBox = new SIPCommMenu(); - private final JLabel smileyTextLabel = new JLabel(); private final JLabel smileyDescriptionLabel = new JLabel(); @@ -49,15 +46,13 @@ public SmileysSelectorBox(ChatWritePanel writePanel) this.chatWritePanel = writePanel; this.setOpaque(false); - this.selectorBox.setOpaque(false); - // Should explicitly remove any border in order to align correctly the // icon. - this.selectorBox.setBorder(BorderFactory.createEmptyBorder()); - this.selectorBox.setIcon(new ImageIcon(ImageLoader + this.setBorder(BorderFactory.createEmptyBorder()); + this.setIcon(new ImageIcon(ImageLoader .getImage(ImageLoader.SMILIES_ICON))); - JPopupMenu popupMenu = this.selectorBox.getPopupMenu(); + JPopupMenu popupMenu = this.getPopupMenu(); popupMenu.setLayout(new GridBagLayout()); popupMenu.setBackground(Color.WHITE); @@ -67,8 +62,6 @@ public SmileysSelectorBox(ChatWritePanel writePanel) * they are not always necessary. */ popupMenu.addPopupMenuListener(this); - - this.add(selectorBox); } /** @@ -97,7 +90,7 @@ private Dimension calculateGridDimensions(int itemsCount) */ public void open() { - this.selectorBox.doClick(); + this.doClick(); } /** @@ -107,12 +100,13 @@ public void open() */ public boolean isMenuSelected() { - return selectorBox.isPopupMenuVisible(); + return isPopupMenuVisible(); } /** * Writes the symbol corresponding to a chosen smiley icon to the write * message area at the end of the current text. + * @param e the ActionEvent that notified us */ public void actionPerformed(ActionEvent e) { @@ -126,34 +120,12 @@ public void actionPerformed(ActionEvent e) 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. */ private static class SmileyMenuItem extends JMenuItem { - /** * The Smiley depicted by this instance. */ @@ -177,6 +149,7 @@ public SmileyMenuItem(Smiley smiley) /** * Changes the static image of the underlying smiley with a dynamic one. * Also shows the description and smiley string in the description area. + * @param e the MouseEvent that notified us */ 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. + * @param e the MouseEvent that notified us */ public void mouseExited(MouseEvent e) { @@ -201,17 +175,11 @@ public void mouseExited(MouseEvent e) 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 @@ -230,27 +198,26 @@ private void clearMouseOverEffects(SmileyMenuItem smileyItem) smileyDescriptionLabel.setText(""); } - /* + /** * Implements PopupMenuListener#popupMenuCanceled(PopupMenuEvent). Does * nothing. + * @param e the PopupMenuEvent */ - public void popupMenuCanceled(PopupMenuEvent e) - { - } + public void popupMenuCanceled(PopupMenuEvent e) {} - /* + /** * Implements * PopupMenuListener#popupMenuWillBecomeInvisible(PopupMenuEvent). Does * nothing. + * @param e the PopupMenuEvent */ - public void popupMenuWillBecomeInvisible(PopupMenuEvent e) - { - } + public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {} - /* + /** * Implements PopupMenuListener#popupMenuWillBecomeVisible(PopupMenuEvent). * Loads the smileys and creates the UI to represent them when they are * first necessary. + * @param e the PopupMenuEvent that notified us */ public void popupMenuWillBecomeVisible(PopupMenuEvent e) { diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/EditTextToolBar.java b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/EditTextToolBar.java index 27c6e4aab..473d254a6 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/EditTextToolBar.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/EditTextToolBar.java @@ -47,6 +47,7 @@ public class EditTextToolBar /** * Creates an instance and constructs the EditTextToolBar. + * @param writePanel the panel containing the chat write area */ public EditTextToolBar(ChatWritePanel writePanel) { @@ -79,7 +80,11 @@ public void actionPerformed(ActionEvent event) this.smileysBox.setToolTipText(GuiActivator.getResources() .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); } /** diff --git a/src/net/java/sip/communicator/impl/gui/main/presence/AccountStatusPanel.java b/src/net/java/sip/communicator/impl/gui/main/presence/AccountStatusPanel.java index fb2e8c800..8e515a76e 100644 --- a/src/net/java/sip/communicator/impl/gui/main/presence/AccountStatusPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/presence/AccountStatusPanel.java @@ -19,34 +19,67 @@ import net.java.sip.communicator.service.protocol.event.*; 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 extends TransparentPanel implements RegistrationStateChangeListener { + /** + * The desired height of the avatar. + */ private static final int AVATAR_ICON_HEIGHT = 45; + /** + * The desired width of the avatar. + */ private static final int AVATAR_ICON_WIDTH = 45; + /** + * The image object storing the avatar. + */ private final FramedImage accountImageLabel; + /** + * The label showing the name of the user. + */ private final JLabel accountNameLabel = new JLabel( GuiActivator .getResources().getI18NString("service.gui.ACCOUNT_ME")); + /** + * The background color property. + */ private final Color bgColor - = new Color( - GuiActivator - .getResources() + = new Color(GuiActivator.getResources() .getColor("service.gui.LOGO_BAR_BACKGROUND")); + /** + * The background image property. + */ private final Image logoBgImage = ImageLoader.getImage(ImageLoader.WINDOW_TITLE_BAR); + /** + * The combo box containing status menu. + */ private final GlobalStatusSelectorBox statusComboBox; + /** + * TexturePaint used to paint background image. + */ private final TexturePaint texture; + /** + * Creates an instance of AccountStatusPanel by specifying the + * main window, where this panel is added. + * @param mainFrame the main window, where this panel is added + */ public AccountStatusPanel(MainFrame mainFrame) { super(new BorderLayout(10, 0)); @@ -96,6 +129,12 @@ public AccountStatusPanel(MainFrame mainFrame) bgImage.getHeight(null))); } + /** + * Adds the account given by protocolProvider in the contained + * status combo box. + * @param protocolProvider the ProtocolProviderService + * corresponding to the account to add + */ public void addAccount(ProtocolProviderService protocolProvider) { statusComboBox.addAccount(protocolProvider); @@ -103,6 +142,12 @@ public void addAccount(ProtocolProviderService protocolProvider) protocolProvider.addRegistrationStateChangeListener(this); } + /** + * Removes the account given by protocolProvider from the contained + * status combo box. + * @param protocolProvider the ProtocolProviderService + * corresponding to the account to remove + */ public void removeAccount(ProtocolProviderService protocolProvider) { statusComboBox.removeAccount(protocolProvider); @@ -110,28 +155,63 @@ public void removeAccount(ProtocolProviderService protocolProvider) protocolProvider.removeRegistrationStateChangeListener(this); } + /** + * Checks if an account corresponding to the given protocolProvider + * is contained in the contained status combo box. + * @param protocolProvider the ProtocolProviderService + * corresponding to the account to check for + * @return true to indicate that an account corresponding to the + * given protocolProvider is contained in the status box, + * false - otherwise + */ public boolean containsAccount(ProtocolProviderService protocolProvider) { return statusComboBox.containsAccount(protocolProvider); } + /** + * Returns the last used presence status for the given + * protocolProvider. + * @param protocolProvider the ProtocolProviderService + * corresponding to the account we're looking for + * @return the last used presence status for the given + * protocolProvider + */ public Object getLastPresenceStatus( ProtocolProviderService protocolProvider) { return statusComboBox.getLastPresenceStatus(protocolProvider); } + /** + * Returns the last used status for the given protocolProvider + * as a String. + * @param protocolProvider the ProtocolProviderService + * corresponding to the account we're looking for + * @return a String representation of the last used status for the given + * protocolProvider + */ public String getLastStatusString(ProtocolProviderService protocolProvider) { return statusComboBox.getLastStatusString(protocolProvider); } + /** + * Updates the current status of the protocolProvider with the + * newStatus. + * @param protocolProvider the ProtocolProviderService to update + * @param newStatus the new status to set + */ public void updateStatus( ProtocolProviderService protocolProvider, PresenceStatus newStatus) { statusComboBox.updateStatus(protocolProvider, newStatus); } + /** + * Updates the current status of the protocolProvider. + * @param protocolProvider the ProtocolProviderService to update + */ public void updateStatus( ProtocolProviderService protocolProvider) { statusComboBox.updateStatus(protocolProvider); @@ -227,6 +307,10 @@ else if (lastName != null) } } + /** + * Paints this component. + * @param g the Graphics object used for painting + */ public void paintComponent(Graphics g) { super.paintComponent(g); diff --git a/src/net/java/sip/communicator/impl/gui/main/presence/GlobalStatusSelectorBox.java b/src/net/java/sip/communicator/impl/gui/main/presence/GlobalStatusSelectorBox.java index 6a069dda0..22d9e9f8a 100644 --- a/src/net/java/sip/communicator/impl/gui/main/presence/GlobalStatusSelectorBox.java +++ b/src/net/java/sip/communicator/impl/gui/main/presence/GlobalStatusSelectorBox.java @@ -42,33 +42,67 @@ public class GlobalStatusSelectorBox extends StatusSelectorMenu implements ActionListener { + /** + * The indent of the image. + */ 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 = 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 ProtocolProviderService and corresponding + * StatusSelectorMenu. + */ private final Map accountMenus = new Hashtable(); + /** + * The main application window. + */ private final MainFrame mainFrame; // private ImageIcon dndIcon = new ImageIcon( // ImageLoader.getImage(ImageLoader.USER_DND_ICON)); + /** + * The item corresponding to the online status. + */ private final JMenuItem onlineItem; + /** + * The item corresponding to the offline status. + */ private final JMenuItem offlineItem; + /** + * The item corresponding to the away status. + */ private final JMenuItem awayItem; // private JMenuItem dndItem = new JMenuItem( -// GuiActivator.getResources().getI18NString("service.gui.DND_STATUS").getText(), +// GuiActivator.getResources().getI18NString("service.gui.DND_STATUS") +// .getText(), // dndIcon); + /** + * The item corresponding to the free for chat status. + */ private final JMenuItem ffcItem; + /** + * The width of the text. + */ private int textWidth = 0; /** @@ -119,6 +153,14 @@ public GlobalStatusSelectorBox(MainFrame mainFrame) computeTextWidth(); } + /** + * Creates a menu item with the given textKey, iconID and + * name. + * @param textKey the text of the item + * @param iconID the icon of the item + * @param name the name of the item + * @return the created JMenuItem + */ private JMenuItem createMenuItem( String textKey, ImageID iconID, @@ -137,6 +179,11 @@ private JMenuItem createMenuItem( return menuItem; } + /** + * Adds a status menu for the account given by protocolProvider. + * @param protocolProvider the ProtocolProviderService, for which + * to add a status menu + */ public void addAccount(ProtocolProviderService protocolProvider) { boolean isHidden @@ -161,6 +208,12 @@ public void addAccount(ProtocolProviderService protocolProvider) this.accountMenus.put(protocolProvider, statusSelectorMenu); } + /** + * Removes the status menu corresponding to the account given by + * protocolProvider. + * @param protocolProvider the ProtocolProviderService, which + * menu to remove + */ public void removeAccount(ProtocolProviderService protocolProvider) { StatusSelectorMenu statusSelectorMenu @@ -170,14 +223,23 @@ public void removeAccount(ProtocolProviderService protocolProvider) this.accountMenus.remove(protocolProvider); } + /** + * Checks if a menu for the given protocolProvider exists. + * @param protocolProvider the ProtocolProviderService to check + * @return true to indicate that a status menu for the given + * protocolProvider already exists, otherwise returns + * false + */ public boolean containsAccount(ProtocolProviderService protocolProvider) { return accountMenus.containsKey(protocolProvider); } /** - * Returns TRUE if there are selected status selector boxes, otherwise - * returns FALSE. + * Returns true if there are selected status selector boxes, + * otherwise returns false. + * @return true if there are selected status selector boxes, + * otherwise returns false */ public boolean hasSelectedMenus() { @@ -190,13 +252,15 @@ public boolean hasSelectedMenus() /** * Handles the ActionEvent triggered when one of the items * in the list is selected. + * @param e the ActionEvent that notified us */ public void actionPerformed(ActionEvent e) { JMenuItem menuItem = (JMenuItem) e.getSource(); String itemName = menuItem.getName(); - Iterator pProviders = mainFrame.getProtocolProviders(); + Iterator pProviders + = mainFrame.getProtocolProviders(); while (pProviders.hasNext()) { @@ -376,9 +440,12 @@ else if (itemName.equals(Constants.AWAY_STATUS)) if (status != null) { - if (currentStatus.getStatus() < PresenceStatus.AVAILABLE_THRESHOLD - && currentStatus.getStatus() >= PresenceStatus.ONLINE_THRESHOLD - && currentStatus.getStatus() > status.getStatus()) + if (currentStatus.getStatus() + < PresenceStatus.AVAILABLE_THRESHOLD + && currentStatus.getStatus() + >= PresenceStatus.ONLINE_THRESHOLD + && currentStatus.getStatus() + > status.getStatus()) { status = currentStatus; } @@ -397,6 +464,11 @@ else if (itemName.equals(Constants.AWAY_STATUS)) } } + /** + * Updates the status of the given protocolProvider. + * @param protocolProvider the ProtocolProviderService + * corresponding to the menu to update + */ public void updateStatus(ProtocolProviderService protocolProvider) { StatusSelectorMenu accountMenu = accountMenus.get(protocolProvider); @@ -435,6 +507,13 @@ public void updateStatus(ProtocolProviderService protocolProvider) this.updateGlobalStatus(); } + /** + * Updates the status of the given protocolProvider with the given + * presenceStatus. + * @param protocolProvider the ProtocolProviderService + * corresponding to the menu to update + * @param presenceStatus the new status to set + */ public void updateStatus(ProtocolProviderService protocolProvider, PresenceStatus presenceStatus) { @@ -540,9 +619,10 @@ private class PublishPresenceStatusThread private OperationSetPresence presence; /** - * - * @param presence - * @param status + * Publishes the given status through the given + * presence operation set. + * @param presence the operation set through which we publish the status + * @param status the status to publish */ public PublishPresenceStatusThread( OperationSetPresence presence, PresenceStatus status) @@ -717,6 +797,7 @@ public String getLastStatusString(ProtocolProviderService protocolProvider) /** * Overwrites the paintComponent(Graphics g) method in order to * provide a new look and the mouse moves over this component. + * @param g the Graphics object used for painting */ 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() {