diff options
author | Yana Stamcheva <yana@jitsi.org> | 2009-11-30 13:43:21 +0000 |
---|---|---|
committer | Yana Stamcheva <yana@jitsi.org> | 2009-11-30 13:43:21 +0000 |
commit | e2c20d0644dfd0116174367fe9934cdb8bb0d6a8 (patch) | |
tree | b1687faa32d3bdecaa28a8bca52903b51a886a7a /src | |
parent | 8672fbb29f5c22354156a9a7a5a42866738687ce (diff) | |
download | jitsi-e2c20d0644dfd0116174367fe9934cdb8bb0d6a8.zip jitsi-e2c20d0644dfd0116174367fe9934cdb8bb0d6a8.tar.gz jitsi-e2c20d0644dfd0116174367fe9934cdb8bb0d6a8.tar.bz2 |
General:
- Enhance the SIPCommMenu to support mouse over fade effects.
Conference invite dialog:
- Add new contacts in the invite dialog by pressing the Enter key.
- Remove selection if the user decides to enter something in the field.
Conference window:
- Replace the call peer arrow icon with a more visible one
- Move the call transfer into the call peer menu (it was previously represented by an icon in the status bar)
- Change the local user background title color in the conference (the grey was looking like disabled)
Diffstat (limited to 'src')
28 files changed, 629 insertions, 390 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommMenu.java b/src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommMenu.java deleted file mode 100644 index ba21090..0000000 --- a/src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommMenu.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.impl.gui.customcontrols; - -import java.awt.event.*; - -import javax.swing.*; - -/** - * The <tt>SIPCommMenu</tt> is very similar to a JComboBox. The main - * component here is a JLabel only with an icon. When user clicks on the icon a - * popup menu is opened, containing a list of icon-text pairs from which the - * user could choose one item. When user selects the desired item, the icon of - * the selected item is set to the main component label. - * - * @author Yana Stamcheva - */ -public class SIPCommMenu - extends JMenu -{ - private static final long serialVersionUID = 1L; - private Object selectedObject; - - /** - * Creates an instance of <tt>SIPCommMenu</tt>. - */ - public SIPCommMenu() - { - super(); - } - - /** - * Creates an instance of <tt>SIPCommMenu</tt> by specifying - * the text and the icon. - */ - public SIPCommMenu(String text, Icon defaultIcon) - { - super(text); - - this.setIcon(defaultIcon); - } - - /** - * Creates an instance of <tt>SIPCommMenu</tt> by specifying the - * initialy selected item. - * - * @param text The item that is initialy selected. - */ - public SIPCommMenu(String text) - { - super(text); - } - - /** - * Adds an item to the "choice list" of this selector box. - * - * @param text The text of the item. - * @param icon The icon of the item. - * @param actionListener The <tt>ActionListener</tt>, which handles the - * case, when the item is selected. - */ - public void addItem(String text, Icon icon, ActionListener actionListener) - { - JMenuItem item = new JMenuItem(text, icon); - - item.addActionListener(actionListener); - - this.add(item); - } - - /** - * Selects the given item. - * - * @param selectedObject The object to select. - */ - public void setSelected(SelectedObject selectedObject) - { - if (selectedObject.getIcon() != null) - this.setIcon(selectedObject.getIcon()); - - if (selectedObject.getText() != null) - this.setText(selectedObject.getText()); - - if (selectedObject.getObject() != null) - this.setSelectedObject(selectedObject.getObject()); - } - - /** - * Selects the given object. - * - * @param o The <tt>Object</tt> to select. - */ - public void setSelectedObject(Object o) - { - this.selectedObject = o; - } - - /** - * Returns the selected object. - * - * @return the selected object. - */ - public Object getSelectedObject() - { - return this.selectedObject; - } - - /** - * Sets the isMouseOver property value and repaints this component. - * - * @param isMouseOver <code>true</code> to indicate that the mouse is over - * this component, <code>false</code> - otherwise. - */ - public void setMouseOver(boolean isMouseOver) - { - this.repaint(); - } -} diff --git a/src/net/java/sip/communicator/impl/gui/main/call/CallManager.java b/src/net/java/sip/communicator/impl/gui/main/call/CallManager.java index b1025f6..e06d496 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/CallManager.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/CallManager.java @@ -12,6 +12,8 @@ import java.util.*; import javax.swing.Timer; +import org.osgi.framework.*; + import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.customcontrols.*; import net.java.sip.communicator.impl.gui.utils.*; @@ -246,6 +248,84 @@ public class CallManager } /** + * Transfers the given <tt>callPeer</tt>. + * @param callPeer the <tt>CallPeer</tt> to transfer + */ + public static void transferCall(CallPeer callPeer) + { + final Call call = callPeer.getCall(); + + if (call != null) + { + OperationSetAdvancedTelephony telephony + = call.getProtocolProvider() + .getOperationSet(OperationSetAdvancedTelephony.class); + + if (telephony != null) + { + final TransferCallDialog dialog = new TransferCallDialog(null); + + /* + * Transferring a call works only when the call is in progress + * so close the dialog (if it's not already closed, of course) + * once the dialog ends. + */ + CallChangeListener callChangeListener = new CallChangeAdapter() + { + /* + * Implements + * CallChangeAdapter#callStateChanged(CallChangeEvent). + */ + public void callStateChanged(CallChangeEvent evt) + { + // we are interested only in CALL_STATE_CHANGEs + if(!evt.getEventType().equals( + CallChangeEvent.CALL_STATE_CHANGE)) + return; + + if (!CallState.CALL_IN_PROGRESS.equals(call + .getCallState())) + { + dialog.setVisible(false); + dialog.dispose(); + } + } + }; + call.addCallChangeListener(callChangeListener); + try + { + dialog.setModal(true); + dialog.pack(); + dialog.setVisible(true); + } + finally + { + call.removeCallChangeListener(callChangeListener); + } + + String target = dialog.getTarget(); + if ((target != null) && (target.length() > 0)) + { + try + { + CallPeer targetPeer = findCallPeer(target); + + if (targetPeer == null) + telephony.transfer(callPeer, target); + else + telephony.transfer(callPeer, targetPeer); + } + catch (OperationFailedException ex) + { + logger.error("Failed to transfer call " + call + " to " + + target, ex); + } + } + } + } + } + + /** * Opens a call dialog. * * @param call the call object to pass to the call dialog @@ -649,4 +729,86 @@ public class CallManager NotificationManager.stopSound(NotificationManager.INCOMING_CALL); NotificationManager.stopSound(NotificationManager.OUTGOING_CALL); } + + /** + * Returns the first <tt>CallPeer</tt> among all existing ones + * who has a specific address. + * + * @param address the address of the <tt>CallPeer</tt> to be located + * @return the first <tt>CallPeer</tt> among all existing ones + * who has the specified <tt>address</tt> + * + * @throws OperationFailedException in case we fail retrieving a reference + * to <tt>ProtocolProviderService</tt>s + */ + private static CallPeer findCallPeer(String address) + throws OperationFailedException + { + BundleContext bundleContext = GuiActivator.bundleContext; + ServiceReference[] serviceReferences; + + try + { + serviceReferences = + bundleContext.getServiceReferences( + ProtocolProviderService.class.getName(), null); + } + catch (InvalidSyntaxException ex) + { + throw new OperationFailedException( + "Failed to retrieve ProtocolProviderService references.", + OperationFailedException.INTERNAL_ERROR, ex); + } + + Class<OperationSetBasicTelephony> telephonyClass + = OperationSetBasicTelephony.class; + CallPeer peer = null; + + for (ServiceReference serviceReference : serviceReferences) + { + ProtocolProviderService service = (ProtocolProviderService) + bundleContext.getService(serviceReference); + OperationSetBasicTelephony telephony = + service.getOperationSet(telephonyClass); + + if (telephony != null) + { + peer = findCallPeer(telephony, address); + if (peer != null) + break; + } + } + return peer; + } + + /** + * Returns the first <tt>CallPeer</tt> known to a specific + * <tt>OperationSetBasicTelephony</tt> to have a specific address. + * + * @param telephony the <tt>OperationSetBasicTelephony</tt> to have its + * <tt>CallPeer</tt>s examined in search for one which has a specific + * address + * @param address the address to locate the associated <tt>CallPeer</tt> of + * @return the first <tt>CallPeer</tt> known to the specified + * <tt>OperationSetBasicTelephony</tt> to have the specified address + */ + private static CallPeer findCallPeer( + OperationSetBasicTelephony telephony, String address) + { + for (Iterator<? extends Call> callIter = telephony.getActiveCalls(); + callIter.hasNext();) + { + Call call = callIter.next(); + + for (Iterator<? extends CallPeer> peerIter = call.getCallPeers(); + peerIter.hasNext();) + { + CallPeer peer = peerIter.next(); + + if (address.equals(peer.getAddress())) + return peer; + } + } + return null; + } } diff --git a/src/net/java/sip/communicator/impl/gui/main/call/TransferCallButton.java b/src/net/java/sip/communicator/impl/gui/main/call/TransferCallButton.java index 8a37202..33708ce 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/TransferCallButton.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/TransferCallButton.java @@ -8,15 +8,10 @@ package net.java.sip.communicator.impl.gui.main.call; import java.awt.*; import java.awt.event.*; -import java.util.*; - -import org.osgi.framework.*; import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.service.protocol.*; -import net.java.sip.communicator.service.protocol.event.*; -import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.swing.*; /** @@ -29,12 +24,6 @@ public class TransferCallButton extends SIPCommButton { /** - * Our class logger. - */ - private static final Logger logger = - Logger.getLogger(TransferCallButton.class); - - /** * The <tt>CallPeer</tt> (whose <tt>Call</tt> is) to be * transfered. */ @@ -45,14 +34,14 @@ public class TransferCallButton * transfer (the <tt>Call</tt> of) a specific * <tt>CallPeer</tt>. * - * @param callPeer the <tt>CallPeer</tt> to be associated + * @param peer the <tt>CallPeer</tt> to be associated * with the new instance and to be transfered */ - public TransferCallButton(CallPeer callPeer) + public TransferCallButton(CallPeer peer) { super(ImageLoader.getImage(ImageLoader.TRANSFER_CALL_BUTTON)); - this.callPeer = callPeer; + this.callPeer = peer; setToolTipText(GuiActivator.getResources().getI18NString( "service.gui.TRANSFER_BUTTON_TOOL_TIP")); @@ -68,179 +57,12 @@ public class TransferCallButton */ public void actionPerformed(ActionEvent evt) { - TransferCallButton.this.actionPerformed(this, evt); + CallManager.transferCall(callPeer); } }); } /** - * Handles actions performed on this button on behalf of a specific - * <tt>ActionListener</tt>. - * - * @param listener the <tt>ActionListener</tt> notified about the - * performing of the action - * @param evt the <tt>ActionEvent</tt> containing the data associated - * with the action and the act of its performing - */ - private void actionPerformed(ActionListener listener, ActionEvent evt) - { - final Call call = callPeer.getCall(); - - if (call != null) - { - OperationSetAdvancedTelephony telephony = - call.getProtocolProvider() - .getOperationSet(OperationSetAdvancedTelephony.class); - - if (telephony != null) - { - final TransferCallDialog dialog = - new TransferCallDialog(getFrame(this)); - - /* - * Transferring a call works only when the call is in progress - * so close the dialog (if it's not already closed, of course) - * once the dialog ends. - */ - CallChangeListener callChangeListener = new CallChangeAdapter() - { - - /* - * Implements - * CallChangeAdapter#callStateChanged(CallChangeEvent). - */ - public void callStateChanged(CallChangeEvent evt) - { - // we are interested only in CALL_STATE_CHANGEs - if(!evt.getEventType().equals( - CallChangeEvent.CALL_STATE_CHANGE)) - return; - - if (!CallState.CALL_IN_PROGRESS.equals(call - .getCallState())) - { - dialog.setVisible(false); - dialog.dispose(); - } - } - }; - call.addCallChangeListener(callChangeListener); - try - { - dialog.setModal(true); - dialog.pack(); - dialog.setVisible(true); - } - finally - { - call.removeCallChangeListener(callChangeListener); - } - - String target = dialog.getTarget(); - if ((target != null) && (target.length() > 0)) - { - try - { - CallPeer targetPeer = findCallPeer(target); - - if (targetPeer == null) - telephony.transfer(callPeer, target); - else - telephony.transfer(callPeer, targetPeer); - } - catch (OperationFailedException ex) - { - logger.error("Failed to transfer call " + call + " to " - + target, ex); - } - } - } - } - } - - /** - * Returns the first <tt>CallPeer</tt> known to a specific - * <tt>OperationSetBasicTelephony</tt> to have a specific address. - * - * @param telephony the <tt>OperationSetBasicTelephony</tt> to have its - * <tt>CallPeer</tt>s examined in search for one which has a specific - * address - * @param address the address to locate the associated <tt>CallPeer</tt> of - * @return the first <tt>CallPeer</tt> known to the specified - * <tt>OperationSetBasicTelephony</tt> to have the specified address - */ - private CallPeer findCallPeer( - OperationSetBasicTelephony telephony, String address) - { - for (Iterator<? extends Call> callIter = telephony.getActiveCalls(); - callIter.hasNext();) - { - Call call = callIter.next(); - - for (Iterator<? extends CallPeer> peerIter = call.getCallPeers(); - peerIter.hasNext();) - { - CallPeer peer = peerIter.next(); - - if (address.equals(peer.getAddress())) - return peer; - } - } - return null; - } - - /** - * Returns the first <tt>CallPeer</tt> among all existing ones - * who has a specific address. - * - * @param address the address of the <tt>CallPeer</tt> to be located - * @return the first <tt>CallPeer</tt> among all existing ones - * who has the specified <tt>address</tt> - * - * @throws OperationFailedException in case we fail retrieving a reference - * to <tt>ProtocolProviderService</tt>s - */ - private CallPeer findCallPeer(String address) - throws OperationFailedException - { - BundleContext bundleContext = GuiActivator.bundleContext; - ServiceReference[] serviceReferences; - - try - { - serviceReferences = - bundleContext.getServiceReferences( - ProtocolProviderService.class.getName(), null); - } - catch (InvalidSyntaxException ex) - { - throw new OperationFailedException( - "Failed to retrieve ProtocolProviderService references.", - OperationFailedException.INTERNAL_ERROR, ex); - } - - Class<OperationSetBasicTelephony> telephonyClass - = OperationSetBasicTelephony.class; - CallPeer peer = null; - - for (ServiceReference serviceReference : serviceReferences) - { - ProtocolProviderService service = (ProtocolProviderService) - bundleContext.getService(serviceReference); - OperationSetBasicTelephony telephony = - service.getOperationSet(telephonyClass); - - if (telephony != null) - { - peer = findCallPeer(telephony, address); - if (peer != null) - break; - } - } - return peer; - } - - /** * Gets the first <tt>Frame</tt> in the ancestor <tt>Component</tt> * hierarchy of a specific <tt>Component</tt>. * <p> 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/CallPeerActionMenuBar.java index 8524e98..b3602c1 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/CallPeerActionMenuBar.java @@ -6,12 +6,12 @@ */ package net.java.sip.communicator.impl.gui.main.call.conference; +import java.awt.*; import java.awt.event.*; import javax.swing.*; import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.impl.gui.customcontrols.*; import net.java.sip.communicator.impl.gui.main.call.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.service.protocol.*; @@ -58,6 +58,8 @@ public class CallPeerActionMenuBar SIPCommMenu menu = new SIPCommMenu(); + menu.setPreferredSize(new Dimension(20, 20)); + this.setOpaque(false); menu.setOpaque(false); @@ -65,8 +67,8 @@ public class CallPeerActionMenuBar // icon. menu.setBorder(BorderFactory.createEmptyBorder()); menu.setIcon(new ImageIcon(ImageLoader - .getImage(ImageLoader.DOWN_ARROW_ICON))); - + .getImage(ImageLoader.CALL_PEER_TOOLS))); + menu.setIconTextGap(0); menu.addItem( GuiActivator.getResources().getI18NString("service.gui.HANG_UP"), null, @@ -84,6 +86,18 @@ public class CallPeerActionMenuBar menu.add(holdMenuItem); menu.add(muteMenuItem); + menu.addItem( + GuiActivator.getResources().getI18NString( + "service.gui.TRANSFER_BUTTON_TOOL_TIP"), + null, + new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + CallManager.transferCall(callPeer); + } + }); + this.add(menu); // Add the call peer listener that would notify us for call peer 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 08ac9dd..e25a2c8 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 @@ -338,16 +338,6 @@ public class ConferencePeerPanel this.addToStatusBar(securityStatusLabel); this.addToStatusBar(holdStatusLabel); this.addToStatusBar(muteStatusLabel); - - Component[] buttons = new Component[] - { - CallPeerRendererUtils.createTransferCallButton(callPeer) - }; - - Component buttonBar - = CallPeerRendererUtils.createButtonBar(false, buttons); - - this.addToStatusBar(buttonBar); } /** diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/history/HistoryMenu.java b/src/net/java/sip/communicator/impl/gui/main/chat/history/HistoryMenu.java index 3063da7..f073ee9 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/history/HistoryMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/history/HistoryMenu.java @@ -12,7 +12,7 @@ import java.awt.event.*; import javax.swing.*; import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.impl.gui.customcontrols.*; +import net.java.sip.communicator.util.swing.*; /** * The <tt>HistoryMenu</tt> is the main menu in the history window. @@ -23,9 +23,15 @@ public class HistoryMenu extends SIPCommMenu implements ActionListener { + /** + * The empty history menu item. + */ private JMenuItem emptyMenuItem = new JMenuItem( GuiActivator.getResources().getI18NString("service.gui.EMPTY_HISTORY")); + /** + * The close menu item. + */ private JMenuItem closeMenuItem = new JMenuItem( GuiActivator.getResources().getI18NString("service.gui.CLOSE")); @@ -63,14 +69,15 @@ public class HistoryMenu /** * Handles the <tt>ActionEvent</tt> when user selects an item from the * menu. When the close item is selected disposes the window. + * @param e the <tt>ActionEvent</tt> that notified us */ - public void actionPerformed(ActionEvent e) { + public void actionPerformed(ActionEvent e) + { JMenuItem menuItem = (JMenuItem) e.getSource(); String menuName = menuItem.getName(); - if (menuName.equalsIgnoreCase("empty")) { - //TODO: Implement - "empty" history. - } else if (menuName.equalsIgnoreCase("service.gui.CLOSE")) { + if (menuName.equalsIgnoreCase("service.gui.CLOSE")) + { this.parentWindow.setVisible(false); this.parentWindow.dispose(); } diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/history/HistoryWindow.java b/src/net/java/sip/communicator/impl/gui/main/chat/history/HistoryWindow.java index 9df82be..a4b7df7 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/history/HistoryWindow.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/history/HistoryWindow.java @@ -99,7 +99,8 @@ public class HistoryWindow * which this <code>HistoryWindow</code> has added itself as a * <code>MessageListener</code>. */ - private java.util.List<OperationSetBasicInstantMessaging> basicInstantMessagings; + private java.util.List<OperationSetBasicInstantMessaging> + basicInstantMessagings; /** * If the <code>historyContact</code> is a <code>ChatRoomWrapper</code>, @@ -245,6 +246,8 @@ public class HistoryWindow /** * Shows the history given by the collection into a ChatConversationPanel. * @param historyRecords a collection of history records + * @return an <tt>HTMLDocument</tt> containing the history given by + * <tt>historyRecords</tt> */ private HTMLDocument createHistory(Collection<Object> historyRecords) { @@ -335,19 +338,22 @@ public class HistoryWindow /** * Implements <tt>ChatConversationContainer.setStatusMessage</tt> method. */ - public void setStatusMessage(String message) - { - //TODO : setStatusMessage(String message) - } + public void setStatusMessage(String message) {} /** * Implements <tt>ChatConversationContainer.getWindow</tt> method. + * @return this window */ public Window getConversationContainerWindow() { return this; } + /** + * Indicates that the window is closing. Removes all message listeners when + * closing. + * @param e the <tt>WindowEvent</tt> that notified us + */ protected void windowClosing(WindowEvent e) { super.windowClosing(e); @@ -387,10 +393,11 @@ public class HistoryWindow else return new Date(System.currentTimeMillis()); } - + /** * Handles the ProgressEvent triggered from the history when processing * a query. + * @param evt the <tt>ProgressEvent</tt> that notified us */ public void progressChanged(ProgressEvent evt) { @@ -523,10 +530,10 @@ public class HistoryWindow } }; SwingUtilities.invokeLater(updateDatesPanel); - } - } + } + } } - + /** * Loads history messages in the right panel. */ @@ -547,7 +554,7 @@ public class HistoryWindow this.startDate = startDate; this.endDate = endDate; } - + public void run() { final Collection<Object> msgList; @@ -590,7 +597,7 @@ public class HistoryWindow SwingUtilities.invokeLater(updateMessagesPanel); } } - + /** * Loads dates found for keyword. */ @@ -609,7 +616,7 @@ public class HistoryWindow { this.keyword = keyword; } - + public void run() { Collection<Object> msgList = null; @@ -663,7 +670,7 @@ public class HistoryWindow } } } - + Runnable updateDatesPanel = new Runnable() { public void run() @@ -706,7 +713,7 @@ public class HistoryWindow } }; SwingUtilities.invokeLater(updateDatesPanel); - } + } } /** @@ -714,6 +721,8 @@ public class HistoryWindow * user presses the Esc key. Checks if the popup menu is visible and if * this is the case hides it, otherwise saves the current history window * size and location and disposes the window. + * @param isEscaped indicates if the window has been closed by pressing the + * Esc key */ protected void close(boolean isEscaped) { @@ -774,7 +783,7 @@ public class HistoryWindow { Contact destContact = evt.getDestinationContact(); Message sourceMessage = evt.getSourceMessage(); - + this.processMessage( destContact, evt.getTimestamp(), @@ -782,10 +791,9 @@ public class HistoryWindow sourceMessage.getContent(), sourceMessage.getContentType()); } - - public void messageDeliveryFailed(MessageDeliveryFailedEvent evt) - {} - + + public void messageDeliveryFailed(MessageDeliveryFailedEvent evt) {} + /** * Processes the message given by the parameters. * @@ -793,6 +801,7 @@ public class HistoryWindow * @param timestamp the timestamp of the message * @param messageType INCOMING or OUTGOING * @param messageContent the content text of the message + * @param messageContentType the content type of the message */ private void processMessage(Contact contact, long timestamp, @@ -853,7 +862,8 @@ public class HistoryWindow /** * Appends the given string at the end of the given html document. - * + * + * @param doc the document to append to * @param chatString the string to append */ private void appendMessageToDocument(HTMLDocument doc, String chatString) @@ -875,12 +885,9 @@ public class HistoryWindow } } - public void messageDelivered(ChatRoomMessageDeliveredEvent evt) - {} + public void messageDelivered(ChatRoomMessageDeliveredEvent evt) {} - public void messageDeliveryFailed(ChatRoomMessageDeliveryFailedEvent evt) - {} + public void messageDeliveryFailed(ChatRoomMessageDeliveryFailedEvent evt) {} - public void messageReceived(ChatRoomMessageReceivedEvent evt) - {} + public void messageReceived(ChatRoomMessageReceivedEvent evt) {} } diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/menus/EditMenu.java b/src/net/java/sip/communicator/impl/gui/main/chat/menus/EditMenu.java index 006c843..453c726 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/menus/EditMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/menus/EditMenu.java @@ -12,9 +12,9 @@ import java.awt.event.*; import javax.swing.*; import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.impl.gui.customcontrols.*; import net.java.sip.communicator.impl.gui.main.chat.*; import net.java.sip.communicator.impl.gui.utils.*; +import net.java.sip.communicator.util.swing.*; /** * The <tt>EditMenu</tt> is the menu in the chat window menu bar, which contains @@ -22,7 +22,8 @@ import net.java.sip.communicator.impl.gui.utils.*; * * @author Yana Stamcheva */ -public class EditMenu extends SIPCommMenu +public class EditMenu + extends SIPCommMenu implements ActionListener { private JMenuItem fontDialogMenuItem = new JMenuItem( diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/menus/FileMenu.java b/src/net/java/sip/communicator/impl/gui/main/chat/menus/FileMenu.java index 4b326a6..3605345 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/menus/FileMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/menus/FileMenu.java @@ -12,11 +12,11 @@ import java.awt.event.*; import javax.swing.*; import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.impl.gui.customcontrols.*; import net.java.sip.communicator.impl.gui.main.chat.*; import net.java.sip.communicator.impl.gui.main.chat.history.*; import net.java.sip.communicator.impl.gui.main.chatroomslist.*; import net.java.sip.communicator.impl.gui.utils.*; +import net.java.sip.communicator.util.swing.*; /** * The <tt>FileMenu</tt> is the menu in the chat window menu bar that contains @@ -24,7 +24,8 @@ import net.java.sip.communicator.impl.gui.utils.*; * * @author Yana Stamcheva */ -public class FileMenu extends SIPCommMenu +public class FileMenu + extends SIPCommMenu implements ActionListener { private JMenuItem myChatRoomsItem = new JMenuItem( diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/menus/HelpMenu.java b/src/net/java/sip/communicator/impl/gui/main/chat/menus/HelpMenu.java index f7820c4..a5f5cc9 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/menus/HelpMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/menus/HelpMenu.java @@ -11,12 +11,12 @@ import java.awt.*; import java.awt.event.*; import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.impl.gui.customcontrols.*; import net.java.sip.communicator.impl.gui.event.*; import net.java.sip.communicator.impl.gui.main.chat.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.gui.Container; import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.swing.*; import org.osgi.framework.*; /** diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/menus/MessageWindowMenuBar.java b/src/net/java/sip/communicator/impl/gui/main/chat/menus/MessageWindowMenuBar.java index c31bcf2..b4dea23 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/menus/MessageWindowMenuBar.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/menus/MessageWindowMenuBar.java @@ -29,7 +29,7 @@ public class MessageWindowMenuBar private final FileMenu fileMenu; private final EditMenu editMenu; - + private final OptionsMenu optionsMenu; private final HelpMenu helpMenu; diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/menus/OptionsMenu.java b/src/net/java/sip/communicator/impl/gui/main/chat/menus/OptionsMenu.java index 909e9f4..c3603f9 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/menus/OptionsMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/menus/OptionsMenu.java @@ -13,9 +13,9 @@ import java.awt.event.*; import javax.swing.*; import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.impl.gui.customcontrols.*; import net.java.sip.communicator.impl.gui.main.chat.*; import net.java.sip.communicator.impl.gui.utils.ConfigurationManager; +import net.java.sip.communicator.util.swing.*; /** * The <tt>OptionMenu</tt> is a menu in the chat window menu bar. * diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactRightButtonMenu.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactRightButtonMenu.java index 0c9808f..f62cb28 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactRightButtonMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactRightButtonMenu.java @@ -27,6 +27,7 @@ import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.gui.Container; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.swing.*; import org.osgi.framework.*; @@ -463,6 +464,7 @@ public class ContactRightButtonMenu /** * Handles the <tt>ActionEvent</tt>. Determines which menu item was * selected and performs the appropriate operations. + * @param e the <tt>ActionEvent</tt> that notified us */ public void actionPerformed(ActionEvent e) { @@ -789,6 +791,11 @@ public class ContactRightButtonMenu } } + /** + * Indicates that a group has been selected during a move operation. Moves + * the selected contact to the selected group. + * @param evt the <tt>ContactListEvent</tt> has + */ public void groupSelected(ContactListEvent evt) { this.moveDialog.dispose(); @@ -816,6 +823,7 @@ public class ContactRightButtonMenu /** * Implements ContactListListener.contactSelected method in order * to move the chosen sub-contact when a meta contact is selected. + * @param evt the <tt>ContactListEvent</tt> that notified us */ public void contactClicked(ContactListEvent evt) { @@ -825,6 +833,7 @@ public class ContactRightButtonMenu /** * Implements ContactListListener.contactSelected method in order * to move the chosen sub-contact when a meta contact is selected. + * @param evt the <tt>ContactListEvent</tt> that notified us */ public void protocolContactClicked(ContactListEvent evt) { diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/GroupRightButtonMenu.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/GroupRightButtonMenu.java index aa1a59b..8a05b8f 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/GroupRightButtonMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/GroupRightButtonMenu.java @@ -24,6 +24,7 @@ import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.gui.Container; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.swing.*; import org.osgi.framework.*; @@ -160,12 +161,14 @@ public class GroupRightButtonMenu } /** - * Handles the <tt>ActionEvent</tt>. The choosen menu item should correspond + * Handles the <tt>ActionEvent</tt>. The chosen menu item should correspond * to an account, where the new contact will be added. We obtain here the - * protocol provider corresponding to the choosen account and show the + * protocol provider corresponding to the chosen account and show the * dialog, where the user could add the contact. + * @param e the <tt>ActionEvent</tt> that notified us */ - public void actionPerformed(ActionEvent e) { + public void actionPerformed(ActionEvent e) + { JMenuItem item = (JMenuItem)e.getSource(); String itemName = item.getName(); @@ -266,6 +269,11 @@ public class GroupRightButtonMenu } } + /** + * Indicates that a new plugin component has been added. Adds it to this + * container if it belongs to it. + * @param event the <tt>PluginComponentEvent</tt> that notified us + */ public void pluginComponentAdded(PluginComponentEvent event) { PluginComponent c = event.getPluginComponent(); @@ -281,6 +289,11 @@ public class GroupRightButtonMenu this.repaint(); } + /** + * Indicates that a new plugin component has been removed. Removes it to + * from this container if it belongs to it. + * @param event the <tt>PluginComponentEvent</tt> that notified us + */ public void pluginComponentRemoved(PluginComponentEvent event) { PluginComponent c = event.getPluginComponent(); diff --git a/src/net/java/sip/communicator/impl/gui/main/menus/FileMenu.java b/src/net/java/sip/communicator/impl/gui/main/menus/FileMenu.java index d885f42..e1c2a96 100644 --- a/src/net/java/sip/communicator/impl/gui/main/menus/FileMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/menus/FileMenu.java @@ -13,7 +13,6 @@ import java.lang.reflect.*; import javax.swing.*; import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.impl.gui.customcontrols.*; import net.java.sip.communicator.impl.gui.main.*; import net.java.sip.communicator.impl.gui.main.account.*; import net.java.sip.communicator.impl.gui.main.chatroomslist.*; @@ -23,6 +22,7 @@ import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.swing.*; /** * The <tt>FileMenu</tt> is a menu in the main application menu bar that diff --git a/src/net/java/sip/communicator/impl/gui/main/menus/HelpMenu.java b/src/net/java/sip/communicator/impl/gui/main/menus/HelpMenu.java index a2fbe3f..02ad459 100644 --- a/src/net/java/sip/communicator/impl/gui/main/menus/HelpMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/menus/HelpMenu.java @@ -10,12 +10,12 @@ import java.awt.*; import java.awt.event.*; import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.impl.gui.customcontrols.*; import net.java.sip.communicator.impl.gui.event.*; import net.java.sip.communicator.impl.gui.main.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.gui.Container; import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.swing.*; import org.osgi.framework.*; @@ -26,7 +26,7 @@ import org.osgi.framework.*; * @author Thomas Hofer */ public class HelpMenu - extends SIPCommMenu + extends SIPCommMenu implements ActionListener, PluginComponentListener { diff --git a/src/net/java/sip/communicator/impl/gui/main/menus/ToolsMenu.java b/src/net/java/sip/communicator/impl/gui/main/menus/ToolsMenu.java index 3f3c29c..808b327 100644 --- a/src/net/java/sip/communicator/impl/gui/main/menus/ToolsMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/menus/ToolsMenu.java @@ -12,13 +12,13 @@ import java.awt.event.*; import javax.swing.*; import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.impl.gui.customcontrols.*; import net.java.sip.communicator.impl.gui.event.*; import net.java.sip.communicator.impl.gui.main.*; import net.java.sip.communicator.impl.gui.main.call.conference.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.gui.Container; import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.swing.*; import org.osgi.framework.*; @@ -143,7 +143,9 @@ public class ToolsMenu } /** - * + * Indicates that a plugin component has been removed. Removes it from this + * container if it is contained in it. + * @param event the <tt>PluginComponentEvent</tt> that notified us */ public void pluginComponentRemoved(PluginComponentEvent event) { @@ -155,6 +157,9 @@ public class ToolsMenu } } + /** + * Registers all menu items. + */ private void registerMenuItems() { UIService uiService = GuiActivator.getUIService(); @@ -179,11 +184,19 @@ public class ToolsMenu this.add(conferenceMenuItem); } + /** + * Registers the preferences item in the MacOS X menu. + * @return <tt>true</tt> if the operation succeeds, otherwise - returns + * <tt>false</tt> + */ private boolean registerConfigMenuItemMacOSX() { return FileMenu.registerMenuItemMacOSX("Preferences", this); } + /** + * Registers the settings item in the MacOS X menu. + */ private void registerConfigMenuItemNonMacOSX() { JMenuItem configMenuItem = new JMenuItem( diff --git a/src/net/java/sip/communicator/impl/gui/main/menus/ViewMenu.java b/src/net/java/sip/communicator/impl/gui/main/menus/ViewMenu.java index 68022d5..150f24c 100644 --- a/src/net/java/sip/communicator/impl/gui/main/menus/ViewMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/menus/ViewMenu.java @@ -9,8 +9,8 @@ package net.java.sip.communicator.impl.gui.main.menus; import java.awt.*; import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.impl.gui.customcontrols.*; import net.java.sip.communicator.impl.gui.main.*; +import net.java.sip.communicator.util.swing.*; /** * The <tt>ViewMenu</tt> is a menu in the main application menu bar. diff --git a/src/net/java/sip/communicator/impl/gui/main/presence/PresenceStatusMenu.java b/src/net/java/sip/communicator/impl/gui/main/presence/PresenceStatusMenu.java index caeb9ca..e447e7a 100644 --- a/src/net/java/sip/communicator/impl/gui/main/presence/PresenceStatusMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/presence/PresenceStatusMenu.java @@ -19,6 +19,7 @@ import net.java.sip.communicator.impl.gui.main.presence.message.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.swing.*; /** * The <tt>StatusSelectorBox</tt> is a <tt>SIPCommMenu</tt> that contains @@ -263,10 +264,6 @@ public class PresenceStatusMenu return lastSelectedStatus; } - public void updateStatus() - { - } - private class PublishPresenceStatusThread extends Thread { diff --git a/src/net/java/sip/communicator/impl/gui/main/presence/StatusSelectorMenu.java b/src/net/java/sip/communicator/impl/gui/main/presence/StatusSelectorMenu.java index 6c983fe..5554774 100644 --- a/src/net/java/sip/communicator/impl/gui/main/presence/StatusSelectorMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/presence/StatusSelectorMenu.java @@ -13,9 +13,9 @@ import java.util.*; import javax.swing.*; import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.impl.gui.customcontrols.*; import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.protocol.*; +import net.java.sip.communicator.util.swing.*; /** * A parent class for all status selector boxes. @@ -28,11 +28,20 @@ import net.java.sip.communicator.service.protocol.*; public abstract class StatusSelectorMenu extends SIPCommMenu { + /** + * Creates a <tt>StatusSelectorMenu</tt>. + */ public StatusSelectorMenu() { super(); } + /** + * Creates a <tt>StatusSelectorMenu</tt> by specifying the text and icon to + * show. + * @param text the text of the menu + * @param defaultIcon the icon of the menu + */ public StatusSelectorMenu(String text, Icon defaultIcon) { super(text, defaultIcon); @@ -69,6 +78,9 @@ public abstract class StatusSelectorMenu * Saves the last status for all accounts. This information is used * on loging. Each time user logs in he's logged with the same status * as he was the last time before closing the application. + * @param protocolProvider the protocol provider to save status information + * for + * @param statusName the name of the status to save */ protected void saveStatusInformation( ProtocolProviderService protocolProvider, diff --git a/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java b/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java index b365b1f..05b58a4 100644 --- a/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java +++ b/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java @@ -742,6 +742,12 @@ public class ImageLoader public static final ImageID DEFAULT_FILE_ICON = new ImageID("service.gui.icons.DEFAULT_FILE_ICON"); + /** + * The tools icon shown in conference calls. + */ + public static final ImageID CALL_PEER_TOOLS + = new ImageID("service.gui.buttons.CALL_PEER_TOOLS"); + /* * ======================================================================= * ------------------------ EDIT TOOLBAR ICONS --------------------------- diff --git a/src/net/java/sip/communicator/impl/gui/utils/InviteDialog.java b/src/net/java/sip/communicator/impl/gui/utils/InviteDialog.java index 7b90d6d..a649212 100644 --- a/src/net/java/sip/communicator/impl/gui/utils/InviteDialog.java +++ b/src/net/java/sip/communicator/impl/gui/utils/InviteDialog.java @@ -40,6 +40,10 @@ public class InviteDialog private final DefaultListModel selectedContactListModel = new DefaultListModel(); + private final SIPCommTextField newContactField + = new SIPCommTextField(GuiActivator.getResources() + .getI18NString("service.gui.OR_ENTER_PHONE_NUMBER")); + /** * Constructs an <tt>InviteDialog</tt>, by specifying the initial list of * contacts available for invite. @@ -165,9 +169,24 @@ public class InviteDialog SIPCommBorders.getRoundBorder()); // New contact text field panel. - final SIPCommTextField newContactField - = new SIPCommTextField(GuiActivator.getResources() - .getI18NString("service.gui.OR_ENTER_PHONE_NUMBER")); + newContactField.getInputMap().put( + KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), + "moveStringFromLeftToRight"); + newContactField.getActionMap().put("moveStringFromLeftToRight", + new MoveStringToRight()); + + newContactField.addFocusListener(new FocusAdapter() + { + /** + * Removes all other selections. + * @param e the <tt>FocusEvent</tt> that notified us + */ + public void focusGained(FocusEvent e) + { + contactList.removeSelectionInterval( + 0, contactList.getMaxSelectionIndex()); + } + }); TransparentPanel leftPanel = new TransparentPanel(new BorderLayout()); leftPanel.setBorder(SIPCommBorders.getRoundBorder()); @@ -203,13 +222,7 @@ public class InviteDialog if (metaContacts != null && metaContacts.length > 0) moveContactsFromLeftToRight(metaContacts); - String newContactText = newContactField.getText(); - - if (newContactText != null && newContactText.length() > 0) - { - moveStringFromLeftToRight(newContactText); - newContactField.setText(""); - } + moveStringFromLeftToRight(); } }); @@ -365,11 +378,15 @@ public class InviteDialog /** * Moves a string from left to right. - * @param text the text to move from left to right */ - private void moveStringFromLeftToRight(String text) + private void moveStringFromLeftToRight() { - selectedContactListModel.addElement(text); + String newContactText = newContactField.getText(); + + if (newContactText != null && newContactText.length() > 0) + selectedContactListModel.addElement(newContactField.getText()); + + newContactField.setText(""); } /** @@ -388,4 +405,17 @@ public class InviteDialog contactListModel.addElement(contact); } } + + /** + * The <tt>MoveStringToRight</tt> is an <tt>AbstractAction</tt> that moves + * the text to right panel containing selected contacts. + */ + private class MoveStringToRight + extends UIAction + { + public void actionPerformed(ActionEvent e) + { + moveStringFromLeftToRight(); + } + } } diff --git a/src/net/java/sip/communicator/util/swing/SIPCommButton.java b/src/net/java/sip/communicator/util/swing/SIPCommButton.java index e0c5e8f..6b1da3a 100755 --- a/src/net/java/sip/communicator/util/swing/SIPCommButton.java +++ b/src/net/java/sip/communicator/util/swing/SIPCommButton.java @@ -67,7 +67,8 @@ public class SIPCommButton /** * Creates a button with custom background image. * - * @param bgImage The background button image. + * @param bgImage the background button image + * @param iconImage the icon of this button */ public SIPCommButton( Image bgImage, Image iconImage) @@ -117,10 +118,13 @@ public class SIPCommButton } } + /** + * Paints this button. + * @param g the <tt>Graphics</tt> object used for painting + */ private void internalPaintComponent(Graphics g) { AntialiasingManager.activateAntialiasing(g); - /* * As JComponent#paintComponent says, if you do not invoke super's * implementation you must honor the opaque property, that is if this diff --git a/src/net/java/sip/communicator/util/swing/SIPCommFrame.java b/src/net/java/sip/communicator/util/swing/SIPCommFrame.java index 8ac2431..a1bf6ab 100644 --- a/src/net/java/sip/communicator/util/swing/SIPCommFrame.java +++ b/src/net/java/sip/communicator/util/swing/SIPCommFrame.java @@ -65,8 +65,8 @@ public abstract class SIPCommFrame amap = rootPane.getActionMap(); amap.put("close", new CloseAction()); - imap = - rootPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + imap + = rootPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); } /** diff --git a/src/net/java/sip/communicator/util/swing/SIPCommMenu.java b/src/net/java/sip/communicator/util/swing/SIPCommMenu.java new file mode 100644 index 0000000..25b7c92 --- /dev/null +++ b/src/net/java/sip/communicator/util/swing/SIPCommMenu.java @@ -0,0 +1,271 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package net.java.sip.communicator.util.swing; + +import java.awt.*; +import java.awt.event.*; + +import javax.swing.*; + +import org.jvnet.lafwidget.animation.*; + +/** + * The <tt>SIPCommMenu</tt> is very similar to a JComboBox. The main + * component here is a JLabel only with an icon. When user clicks on the icon a + * popup menu is opened, containing a list of icon-text pairs from which the + * user could choose one item. When user selects the desired item, the icon of + * the selected item is set to the main component label. + * + * @author Yana Stamcheva + */ +public class SIPCommMenu + extends JMenu +{ + private static final long serialVersionUID = 1L; + private Object selectedObject; + + /** + * Creates an instance of <tt>SIPCommMenu</tt>. + */ + public SIPCommMenu() + { + super(); + init(); + } + + /** + * Creates an instance of <tt>SIPCommMenu</tt> by specifying + * the text and the icon. + */ + public SIPCommMenu(String text, Icon defaultIcon) + { + super(text); + + this.setIcon(defaultIcon); + init(); + } + + /** + * Creates an instance of <tt>SIPCommMenu</tt> by specifying the + * initialy selected item. + * + * @param text The item that is initialy selected. + */ + public SIPCommMenu(String text) + { + super(text); + init(); + } + + private void init() + { + MouseRolloverHandler mouseHandler = new MouseRolloverHandler(); + + this.addMouseListener(mouseHandler); + this.addMouseMotionListener(mouseHandler); + } + + /** + * Adds an item to the "choice list" of this selector box. + * + * @param text The text of the item. + * @param icon The icon of the item. + * @param actionListener The <tt>ActionListener</tt>, which handles the + * case, when the item is selected. + */ + public void addItem(String text, Icon icon, ActionListener actionListener) + { + JMenuItem item = new JMenuItem(text, icon); + + item.addActionListener(actionListener); + + this.add(item); + } + + /** + * Selects the given item. + * + * @param selectedObject The object to select. + */ + public void setSelected(SelectedObject selectedObject) + { + if (selectedObject.getIcon() != null) + this.setIcon(selectedObject.getIcon()); + + if (selectedObject.getText() != null) + this.setText(selectedObject.getText()); + + if (selectedObject.getObject() != null) + this.setSelectedObject(selectedObject.getObject()); + } + + /** + * Selects the given object. + * + * @param o The <tt>Object</tt> to select. + */ + public void setSelectedObject(Object o) + { + this.selectedObject = o; + } + + /** + * Returns the selected object. + * + * @return the selected object. + */ + public Object getSelectedObject() + { + return this.selectedObject; + } + + /** + * Sets the isMouseOver property value and repaints this component. + * + * @param isMouseOver <code>true</code> to indicate that the mouse is over + * this component, <code>false</code> - otherwise. + */ + public void setMouseOver(boolean isMouseOver) + { + this.repaint(); + } + + /** + * Paints this component. + * @param g the <tt>Graphics</tt> object used for painting + */ + public void paintComponent(Graphics g) + { + g = g.create(); + try + { + internalPaintComponent(g); + } + finally + { + g.dispose(); + } + } + + /** + * Paints a rollover effect when the mouse is over this menu. + * @param g the <tt>Graphics</tt> object used for painting + */ + private void internalPaintComponent(Graphics g) + { + AntialiasingManager.activateAntialiasing(g); + + // Paint a roll over fade out. + FadeTracker fadeTracker = FadeTracker.getInstance(); + + float visibility = getModel().isRollover() ? 1.0f : 0.0f; + if (fadeTracker.isTracked(this, FadeKind.ROLLOVER)) + { + visibility = fadeTracker.getFade(this, FadeKind.ROLLOVER); + } + + visibility /= 2; + + g.setColor(new Color(1.0f, 1.0f, 1.0f, visibility)); + + g.fillRoundRect(0, 0, this.getWidth(), this.getHeight(), 10, 10); + + g.setColor(UIManager.getColor("Menu.foreground")); + + super.paintComponent(g); + } + + /** + * The <tt>ButtonRepaintCallback</tt> is charged to repaint this button + * when the fade animation is performed. + */ + private class ButtonRepaintCallback implements FadeTrackerCallback + { + public void fadeEnded(FadeKind arg0) + { + repaintLater(); + } + + public void fadePerformed(FadeKind arg0, float arg1) + { + repaintLater(); + } + + private void repaintLater() + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + SIPCommMenu.this.repaint(); + } + }); + } + + public void fadeReversed(FadeKind arg0, boolean arg1, float arg2) + { + } + } + + /** + * Perform a fade animation on mouse over. + */ + private class MouseRolloverHandler + implements MouseListener, + MouseMotionListener + { + public void mouseMoved(MouseEvent e) + { + } + + public void mouseExited(MouseEvent e) + { + if (isEnabled()) + { + getModel().setRollover(false); + + FadeTracker fadeTracker = FadeTracker.getInstance(); + + fadeTracker.trackFadeOut(FadeKind.ROLLOVER, + SIPCommMenu.this, + true, + new ButtonRepaintCallback()); + } + } + + public void mouseClicked(MouseEvent e) + { + } + + public void mouseEntered(MouseEvent e) + { + if (isEnabled()) + { + getModel().setRollover(true); + + FadeTracker fadeTracker = FadeTracker.getInstance(); + + fadeTracker.trackFadeIn(FadeKind.ROLLOVER, + SIPCommMenu.this, + true, + new ButtonRepaintCallback()); + } + } + + public void mousePressed(MouseEvent e) + { + } + + public void mouseReleased(MouseEvent e) + { + } + + public void mouseDragged(MouseEvent e) + { + } + } +} diff --git a/src/net/java/sip/communicator/util/swing/SIPCommMenuBar.java b/src/net/java/sip/communicator/util/swing/SIPCommMenuBar.java index 45d4d4e..10fa699 100644 --- a/src/net/java/sip/communicator/util/swing/SIPCommMenuBar.java +++ b/src/net/java/sip/communicator/util/swing/SIPCommMenuBar.java @@ -19,6 +19,8 @@ import net.java.sip.communicator.util.swing.plaf.*; public class SIPCommMenuBar extends JMenuBar { + private boolean isRollover; + public SIPCommMenuBar() { this.setBorder(BorderFactory.createEmptyBorder()); diff --git a/src/net/java/sip/communicator/util/swing/SIPCommTextField.java b/src/net/java/sip/communicator/util/swing/SIPCommTextField.java index 5475da3..8a45bd6 100644 --- a/src/net/java/sip/communicator/util/swing/SIPCommTextField.java +++ b/src/net/java/sip/communicator/util/swing/SIPCommTextField.java @@ -106,9 +106,9 @@ public class SIPCommTextField */ public void setText(String text) { - if (text != null && text.length() > 0) - super.setText(text); - else + super.setText(text); + + if ((text == null || text.length() == 0) && !isFocusOwner()) setDefaultText(); } diff --git a/src/net/java/sip/communicator/impl/gui/customcontrols/SelectedObject.java b/src/net/java/sip/communicator/util/swing/SelectedObject.java index b57f400..edd343d 100644 --- a/src/net/java/sip/communicator/impl/gui/customcontrols/SelectedObject.java +++ b/src/net/java/sip/communicator/util/swing/SelectedObject.java @@ -4,7 +4,7 @@ * Distributable under LGPL license. * See terms of license at gnu.org. */ -package net.java.sip.communicator.impl.gui.customcontrols; +package net.java.sip.communicator.util.swing; import javax.swing.*; |