diff --git a/resources/images/images.properties b/resources/images/images.properties index a79014ae1..7bbec63aa 100644 --- a/resources/images/images.properties +++ b/resources/images/images.properties @@ -98,6 +98,9 @@ service.gui.icons.CHANGE_NICKNAME_16x16=resources/images/impl/gui/common/changeN service.gui.icons.BAN_16x16=resources/images/impl/gui/common/ban16x16.png service.gui.icons.KICK_16x16=resources/images/impl/gui/common/kick16x16.png service.gui.icons.VOICEMAIL=resources/images/impl/gui/common/voicemail.png +service.gui.icons.SEND_SMS=resources/images/impl/gui/common/sms.png +service.gui.icons.SEND_SMS_SELECTED=resources/images/impl/gui/common/smsSelected.png +service.gui.icons.TYPING=resources/images/impl/gui/common/typing.gif # Status icons service.gui.statusicons.USER_ONLINE_ICON=resources/images/impl/gui/common/statusicons/online.png diff --git a/resources/images/impl/gui/buttons/fontIcon.png b/resources/images/impl/gui/buttons/fontIcon.png index 6c9bb11d1..700cb0d0f 100644 Binary files a/resources/images/impl/gui/buttons/fontIcon.png and b/resources/images/impl/gui/buttons/fontIcon.png differ diff --git a/resources/images/impl/gui/buttons/smiley.png b/resources/images/impl/gui/buttons/smiley.png index dac87bb6f..b16f70045 100644 Binary files a/resources/images/impl/gui/buttons/smiley.png and b/resources/images/impl/gui/buttons/smiley.png differ diff --git a/resources/images/impl/gui/common/sms.png b/resources/images/impl/gui/common/sms.png new file mode 100644 index 000000000..69b4b3cc3 Binary files /dev/null and b/resources/images/impl/gui/common/sms.png differ diff --git a/resources/images/impl/gui/common/smsSelected.png b/resources/images/impl/gui/common/smsSelected.png new file mode 100644 index 000000000..7481b26bb Binary files /dev/null and b/resources/images/impl/gui/common/smsSelected.png differ diff --git a/resources/images/impl/gui/common/src/gsm.svg b/resources/images/impl/gui/common/src/gsm.svg index 521a2e0f8..27bae288b 100644 --- a/resources/images/impl/gui/common/src/gsm.svg +++ b/resources/images/impl/gui/common/src/gsm.svg @@ -1,8 +1,9 @@ + + inkscape:output_extension="org.inkscape.output.svg.inkscape" + version="1.1"> + id="defs4"> + + + + + + + + + + + + + + + + inkscape:window-y="0" + showgrid="false" + inkscape:window-maximized="0" /> @@ -45,6 +130,7 @@ image/svg+xml + @@ -52,276 +138,145 @@ inkscape:label="Layer 1" inkscape:groupmode="layer" id="layer1"> - - - + + id="g3791" + transform="translate(12.111263,-0.36261268)" + inkscape:export-filename="/Users/yanastamcheva/workspace/trunk1/resources/images/impl/gui/common/sms.png" + inkscape:export-xdpi="147.98357" + inkscape:export-ydpi="147.98357"> + + - - - - - - - - - - - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - * - 0 - # + style="fill:#474747;fill-opacity:0.76470588;stroke:none" /> + + + + + + + diff --git a/resources/images/impl/gui/common/typing.gif b/resources/images/impl/gui/common/typing.gif new file mode 100644 index 000000000..fa352eebc Binary files /dev/null and b/resources/images/impl/gui/common/typing.gif differ diff --git a/resources/languages/resources.properties b/resources/languages/resources.properties index d199206ea..87f746348 100644 --- a/resources/languages/resources.properties +++ b/resources/languages/resources.properties @@ -83,6 +83,7 @@ service.gui.CALL_VIA=Call via: service.gui.CALL_NOT_SUPPORTING_PARTICIPANT=This call only supports participants from the {0} network and your {1} account. {2} does not contain any address for this network or account. service.gui.CANCEL=&Cancel service.gui.CHAT=Chat +service.gui.CHANGE_FONT=Change font service.gui.CHANGE_ROOM_SUBJECT=Change room's subject... service.gui.CHANGE_ROOM_SUBJECT_LABEL=In the field below, you can enter the new subject for this room. service.gui.CHANGE_NICKNAME=Change nickname... @@ -129,7 +130,6 @@ service.gui.CONTACT_NOT_SUPPORTING_TELEPHONY=The chosen {0} contact doesn''t sup service.gui.CONTACT_NOT_SUPPORTING_CHAT_CONF=The chosen {0} contact doesn''t support chat conferencing. service.gui.CONTACT_PAUSED_TYPING={0} paused typing the message service.gui.CONTACT_TYPING={0} is typing a message -service.gui.CONTACT_TYPING_STATE_STALE=typing state not updated service.gui.CONTACT_INFO=&Contact info service.gui.CONTACTS=Contacts service.gui.COPY=&Copy @@ -424,6 +424,7 @@ service.gui.UNKNOWN=Unknown user service.gui.UNKNOWN_STATUS=Unknown state service.gui.UNREGISTERED_MESSAGE=Unable to connect the following account: User name: {0}, Server name: {1}. You are currently offline. service.gui.VIDEO_CALL=&Video call +service.gui.VIA_SMS=Via SMS service.gui.VIEW=&View service.gui.VIEW_HISTORY=View &history service.gui.VIEW_SMILEYS=View &smileys diff --git a/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommSelectorMenuUI.java b/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommSelectorMenuUI.java deleted file mode 100644 index 392ec0ab0..000000000 --- a/src/net/java/sip/communicator/impl/gui/lookandfeel/SIPCommSelectorMenuUI.java +++ /dev/null @@ -1,80 +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.lookandfeel; - -import java.awt.*; - -import javax.swing.*; -import javax.swing.plaf.*; -import javax.swing.plaf.basic.*; - -import net.java.sip.communicator.impl.gui.utils.*; -import net.java.sip.communicator.util.skin.*; -import net.java.sip.communicator.util.swing.*; - -/** - * The SIPCommSelectorMenuUI implementation. - * - * @author Yana Stamcheva - * @author Adam Netocny - */ -public class SIPCommSelectorMenuUI - extends BasicMenuUI - implements Skinnable -{ - private Image menuBgImage - = ImageLoader.getImage(ImageLoader.STATUS_SELECTOR_BOX); - - /** - * Creates a new SIPCommSelectorMenuUI instance. - * - * @param c the component for which we create the UI - * @return the created ComponentUI - */ - public static ComponentUI createUI(JComponent c) - { - return new SIPCommSelectorMenuUI(); - } - - /** - * Draws the background of the menu item. - * - * @param g the paint graphics - * @param menuItem menu item to be painted - * @param bgColor selection background color - * @since 1.4 - */ - protected void paintBackground( Graphics g, - JMenuItem menuItem, - Color bgColor) - { - g = g.create(); - - try - { - AntialiasingManager.activateAntialiasing(g); - - int menuWidth = menuItem.getWidth(); - int menuHeight = menuItem.getHeight(); - - g.drawImage(menuBgImage, 0, 0, menuWidth, menuHeight, null); - } - finally - { - g.dispose(); - } - } - - /** - * Reloads the background icon. - */ - public void loadSkin() - { - menuBgImage - = ImageLoader.getImage(ImageLoader.STATUS_SELECTOR_BOX); - } -} diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationContainer.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationContainer.java index a744c681d..63d530028 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationContainer.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationContainer.java @@ -30,5 +30,5 @@ public interface ChatConversationContainer * * @param statusMessage the status message to set */ - public void setStatusMessage(String statusMessage); + public void addTypingNotification(String statusMessage); } diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java index 3ccdfd160..df9d3ac42 100755 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java @@ -150,6 +150,17 @@ public class ChatConversationPanel */ private boolean scrollToBottomIsPending = false; + /** + * The label showing current typing notification. + */ + private JLabel typingNotificationLabel; + + /** + * The typing notification icon. + */ + private final Icon typingIcon = GuiActivator.getResources() + .getImage("service.gui.icons.TYPING"); + /** * The implementation of the routine which scrolls {@link #chatTextPane} to its * bottom. @@ -203,7 +214,10 @@ public ChatConversationPanel(ChatConversationContainer chatContainer) this.setWheelScrollingEnabled(true); - this.setViewportView(chatTextPane); + JPanel viewportView = new TransparentPanel(new BorderLayout()); + viewportView.add(chatTextPane); + + this.setViewportView(viewportView); this.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); @@ -279,7 +293,7 @@ public void componentResized(ComponentEvent e) } } }; - chatTextPane.addComponentListener(componentListener); + viewportView.addComponentListener(componentListener); getViewport().addComponentListener(componentListener); } @@ -1380,6 +1394,55 @@ public void addComponent(ChatConversationComponent component) } } + /** + * Adds a typing notification message to the conversation panel. + * + * @param typingNotification the typing notification to show + */ + public void addTypingNotification(String typingNotification) + { + if (typingNotificationLabel == null) + { + typingNotificationLabel + = new JLabel( typingNotification, + typingIcon, + SwingConstants.CENTER); + typingNotificationLabel.setForeground(Color.GRAY); + typingNotificationLabel.setFont( + typingNotificationLabel.getFont().deriveFont(11f)); + typingNotificationLabel.setVerticalTextPosition(JLabel.BOTTOM); + typingNotificationLabel.setHorizontalTextPosition(JLabel.LEFT); + typingNotificationLabel.setIconTextGap(0); + ((JComponent) getViewport().getView()).add( + typingNotificationLabel, BorderLayout.SOUTH); + } + else + { + typingNotificationLabel.setText(typingNotification); + + if (typingNotification != null && typingNotification.length() > 0) + typingNotificationLabel.setIcon(typingIcon); + else + typingNotificationLabel.setIcon(null); + } + + synchronized (scrollToBottomRunnable) + { + scrollToBottomIsPending = true; + } + + revalidate(); + repaint(); + } + + /** + * Removes the typing notification message from the conversation panel. + */ + public void removeTypingNotification() + { + addTypingNotification(""); + } + /** * Returns the date string to show for the given date. * diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java index 02f8de36a..660de8887 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java @@ -63,23 +63,14 @@ public class ChatPanel private final JSplitPane messagePane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); - private final JCheckBox sendSmsCheckBox = new SIPCommCheckBox( - GuiActivator.getResources().getI18NString("service.gui.SEND_AS_SMS")); - private JSplitPane topSplitPane; - private ChatTransportSelectorBox transportSelectorBox; - - private JLabel sendViaLabel; - private final ChatConversationPanel conversationPanel; private final ChatWritePanel writeMessagePanel; private ChatRoomMemberListPanel chatContactListPanel; - private final ChatSendPanel sendPanel; - private final ChatContainer chatContainer; private ChatRoomSubjectPanel subjectPanel; @@ -119,6 +110,8 @@ public class ChatPanel private boolean isHistoryLoaded; + private int autoDividerLocation = 0; + /** * Stores all active file transfer requests and effective transfers with * the identifier of the transfer. @@ -142,28 +135,18 @@ public ChatPanel(ChatContainer chatContainer) this.conversationPanel.getChatTextPane() .setTransferHandler(new ChatTransferHandler(this)); - this.sendPanel = new ChatSendPanel(this); - this.writeMessagePanel = new ChatWritePanel(this); - int chatAreaSize = ConfigurationManager.getChatWriteAreaSize(); - Dimension writeMessagePanelDefaultSize - = new Dimension(500, (chatAreaSize > 0) ? chatAreaSize : 100); - Dimension writeMessagePanelMinSize = new Dimension(500, 45); - - this.writeMessagePanel.setMinimumSize(writeMessagePanelMinSize); - this.writeMessagePanel.setPreferredSize(writeMessagePanelDefaultSize); - this.messagePane.setBorder(null); this.messagePane.setOpaque(false); this.messagePane.addPropertyChangeListener( new DividerLocationListener()); + this.messagePane.setDividerSize(3); this.messagePane.setResizeWeight(1.0D); this.messagePane.setBottomComponent(writeMessagePanel); this.add(messagePane, BorderLayout.CENTER); - this.add(sendPanel, BorderLayout.SOUTH); if (OSUtils.IS_MAC) { @@ -251,16 +234,7 @@ public void setChatSession(ChatSession chatSession) this.repaint(); } - initChatTransportSelectorBox(); - - if (!transportSelectorBox.getMenu().isEnabled()) - { - // Show a message to the user that IM is not possible. - getChatConversationPanel().appendMessageToEnd("
" + - GuiActivator.getResources(). - getI18NString("service.gui.MSG_NOT_POSSIBLE") + - "
"); - } + writeMessagePanel.setTransportSelectorBoxVisible(true); //Enables to change the protocol provider by simply pressing the // CTRL-P key combination @@ -279,7 +253,7 @@ else if (chatSession instanceof ConferenceChatSession) ConferenceChatSession confSession = (ConferenceChatSession) chatSession; - removeChatTransportSelectorBox(); + writeMessagePanel.setTransportSelectorBoxVisible(false); confSession.addLocalUserRoleListener(this); confSession.addMemberRoleListener(this); @@ -301,9 +275,6 @@ else if (chatSession instanceof ConferenceChatSession) while (chatParticipants.hasNext()) chatContactListPanel.addContact(chatParticipants.next()); } - - if (!chatSession.getCurrentChatTransport().allowsSmsMessage()) - sendSmsCheckBox.setEnabled(false); } /** @@ -315,17 +286,6 @@ public ChatSession getChatSession() return chatSession; } - /** - * Shows or hides the Stylebar depending on the value of parameter b. - * - * @param b if true, makes the Stylebar visible, otherwise hides the - * Stylebar - */ - public void setStylebarVisible(boolean b) - { - this.writeMessagePanel.setStylebarVisible(b); - } - /** * Runs clean-up for associated resources which need explicit disposal (e.g. * listeners keeping this instance alive because they were added to the @@ -362,13 +322,21 @@ public Window getConversationContainerWindow() } /** - * Sets the message text to the status panel in the bottom of the chat - * window. Used to show typing notification messages, links' hrefs, etc. - * @param statusMessage The message text to be displayed. + * Adds a typing notification message to the conversation panel. + * + * @param typingNotification the typing notification string + */ + public void addTypingNotification(String typingNotification) + { + conversationPanel.addTypingNotification(typingNotification); + } + + /** + * Removes the typing notification message from the conversation panel. */ - public void setStatusMessage(String statusMessage) + public void removeTypingNotification() { - this.sendPanel.getStatusPanel().setStatusMessage(statusMessage); + conversationPanel.removeTypingNotification(); } /** @@ -391,16 +359,6 @@ public ChatWritePanel getChatWritePanel() return this.writeMessagePanel; } - /** - * Returns the send panel, contained in this chat panel. - * - * @return the send panel, contained in this chat panel - */ - public ChatSendPanel getChatSendPanel() - { - return this.sendPanel; - } - /** * Returns the corresponding role description to the given role index. * @@ -876,10 +834,19 @@ public void paste() */ public void sendButtonDoClick() { - JButton sendButton = this.sendPanel.getSendButton(); + if (!isWriteAreaEmpty()) + { + new Thread() + { + public void run() + { + sendMessage(); + } + }.start(); + } - sendButton.requestFocus(); - sendButton.doClick(); + //make sure the focus goes back to the write area + requestFocusInWriteArea(); } /** @@ -1148,7 +1115,7 @@ public void sendFile(final File file) */ protected void sendMessage() { - if (sendSmsCheckBox.isSelected()) + if (writeMessagePanel.isSmsSelected()) { this.sendSmsMessage(); } @@ -1311,59 +1278,6 @@ protected void sendInstantMessage() this.refreshWriteArea(); } - /** - * Initializes the send via label and selector box. - */ - private void initChatTransportSelectorBox() - { - // Initialize the "send via" selector box and adds it to the send panel. - if (transportSelectorBox == null) - { - transportSelectorBox = new ChatTransportSelectorBox( - chatSession, chatSession.getCurrentChatTransport()); - - sendViaLabel = new JLabel( - GuiActivator.getResources().getI18NString( - "service.gui.SEND_VIA")); - } - - JPanel sendPanel = getChatSendPanel().getSendPanel(); - sendPanel.add(transportSelectorBox, 0); - sendPanel.add(sendViaLabel, 0); - - updateSendButtonStatus(); - - this.revalidate(); - this.repaint(); - } - - /** - * Sets the send button to the same state (enabled/ disabled) as the - * transportSelectorBox. - */ - private void updateSendButtonStatus() - { - getChatSendPanel().getSendButton(). - setEnabled(transportSelectorBox.getMenu().isEnabled()); - } - - /** - * Removes the send via selector box and label. - */ - private void removeChatTransportSelectorBox() - { - if (transportSelectorBox == null) - return; - - JPanel sendPanel = getChatSendPanel().getSendPanel(); - - sendPanel.remove(transportSelectorBox); - sendPanel.remove(sendViaLabel); - - this.revalidate(); - this.repaint(); - } - /** * Listens for SMS messages and shows them in the chat. */ @@ -1557,7 +1471,7 @@ private void loadHistoryPeriod() */ public void setSmsSelected(boolean isSmsSelected) { - sendSmsCheckBox.setSelected(isSmsSelected); + writeMessagePanel.setSmsSelected(isSmsSelected); } /** @@ -1569,12 +1483,7 @@ private class ChangeTransportAction { public void actionPerformed(ActionEvent e) { - /* - * Opens the selector box containing the protocol contact icons. - * This is the menu, where user could select the protocol specific - * contact to communicate through. - */ - transportSelectorBox.getMenu().doClick(); + writeMessagePanel.openChatTransportSelectorBox(); } } @@ -1608,9 +1517,7 @@ public void setContactName(ChatContact chatContact, String name) */ public void addChatTransport(ChatTransport chatTransport) { - if (transportSelectorBox != null) - transportSelectorBox.addChatTransport(chatTransport); - updateSendButtonStatus(); + writeMessagePanel.addChatTransport(chatTransport); } /** @@ -1620,9 +1527,7 @@ public void addChatTransport(ChatTransport chatTransport) */ public void removeChatTransport(ChatTransport chatTransport) { - if (transportSelectorBox != null) - transportSelectorBox.removeChatTransport(chatTransport); - updateSendButtonStatus(); + writeMessagePanel.removeChatTransport(chatTransport); } /** @@ -1632,8 +1537,7 @@ public void removeChatTransport(ChatTransport chatTransport) */ public void setSelectedChatTransport(ChatTransport chatTransport) { - if (transportSelectorBox != null) - transportSelectorBox.setSelected(chatTransport); + writeMessagePanel.setSelectedChatTransport(chatTransport); } /** @@ -1643,8 +1547,7 @@ public void setSelectedChatTransport(ChatTransport chatTransport) */ public void updateChatTransportStatus(ChatTransport chatTransport) { - if (transportSelectorBox != null) - transportSelectorBox.updateTransportStatus(chatTransport); + writeMessagePanel.updateChatTransportStatus(chatTransport); // Show a status message to the user. this.addMessage( @@ -2154,15 +2057,65 @@ public void propertyChange(PropertyChangeEvent evt) .equals(JSplitPane.DIVIDER_LOCATION_PROPERTY)) { int dividerLocation = (Integer) evt.getNewValue(); - int writeAreaSize = messagePane.getHeight() - dividerLocation - - messagePane.getDividerSize(); - ConfigurationManager - .setChatWriteAreaSize(writeAreaSize); + // We store the divider location only when the user drags the + // divider and not when we've set it programatically. + if (dividerLocation != autoDividerLocation) + { + int writeAreaSize + = messagePane.getHeight() - dividerLocation + - messagePane.getDividerSize(); + + ConfigurationManager + .setChatWriteAreaSize(writeAreaSize); + + writeMessagePanel.setPreferredSize( + new Dimension( + (int) writeMessagePanel.getPreferredSize() + .getWidth(), + writeAreaSize)); + } } } } + /** + * Sets the location of the split pane divider. + * + * @param location the location of the divider given by the pixel count + * between the left bottom corner and the left bottom divider location + */ + public void setDividerLocation(int location) + { + int dividerLocation = messagePane.getHeight() - location; + + autoDividerLocation = dividerLocation; + + messagePane.setDividerLocation(dividerLocation); + messagePane.revalidate(); + messagePane.repaint(); + } + + /** + * Returns the contained divider location. + * + * @return the contained divider location + */ + public int getDividerLocation() + { + return messagePane.getHeight() - messagePane.getDividerLocation(); + } + + /** + * Returns the contained divider size. + * + * @return the contained divider size + */ + public int getDividerSize() + { + return messagePane.getDividerSize(); + } + /** * Adds all events accumulated in the incoming event buffer to the * chat conversation panel. @@ -2362,6 +2315,47 @@ public void promptRepaint() this.getChatWritePanel().getEditorPane().repaint(); } + + /** + * Shows the font chooser dialog + */ + public void showFontChooserDialog() + { + JEditorPane editorPane = writeMessagePanel.getEditorPane(); + FontChooser fontChooser = new FontChooser(); + + fontChooser.setFontFamily( + editorPane.getFont().getFontName()); + fontChooser.setFontSize( + editorPane.getFont().getSize()); + + fontChooser.setBoldStyle(editorPane.getFont().isBold()); + fontChooser.setItalicStyle(editorPane.getFont().isItalic()); + + int result = fontChooser.showDialog(this); + + if (result == FontChooser.OK_OPTION) + { + // Font family and size + writeMessagePanel.setFontFamilyAndSize( + fontChooser.getFontFamily(), + fontChooser.getFontSize()); + + // Font style + writeMessagePanel.setBoldStyleEnable( + fontChooser.isBoldStyleSelected()); + writeMessagePanel.setItalicStyleEnable( + fontChooser.isItalicStyleSelected()); + writeMessagePanel.setUnderlineStyleEnable( + fontChooser.isUnderlineStyleSelected()); + + // Font color + writeMessagePanel.setFontColor(fontChooser.getFontColor()); + } + + editorPane.requestFocus(); + } + /** * Reloads chat messages. */ diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatSendPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatSendPanel.java deleted file mode 100755 index d1910ada6..000000000 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatSendPanel.java +++ /dev/null @@ -1,126 +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.main.chat; - -import java.awt.*; -import java.awt.event.*; - -import javax.swing.*; - -import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.util.*; -import net.java.sip.communicator.util.swing.*; - -/** - * The ChatSendPanel is the panel in the bottom of the chat. It - * contains the send button, the status panel, where typing notifications are - * shown and the selector box, where the protocol specific contact is chosen. - * - * @author Yana Stamcheva - */ -public class ChatSendPanel - extends TransparentPanel - implements ActionListener -{ - private final JButton sendButton; - - private final StatusPanel statusPanel = new StatusPanel(); - - private final TransparentPanel sendPanel - = new TransparentPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0)); - - private final ChatPanel chatPanel; - - /** - * Creates an instance of ChatSendPanel. - * - * @param chatPanel The parent ChatPanel. - */ - public ChatSendPanel(ChatPanel chatPanel) - { - super(new BorderLayout(5, 0)); - - // MacOS would add a default border, so we just add a border for - // other operating systems. - if (!OSUtils.IS_MAC) - this.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); - - sendButton = new JButton( - GuiActivator.getResources().getI18NString("service.gui.SEND")); - - this.chatPanel = chatPanel; - - this.sendPanel.add(sendButton); - - this.add(statusPanel, BorderLayout.CENTER); - this.add(sendPanel, BorderLayout.EAST); - - this.sendButton.addActionListener(this); - this.sendButton.setMnemonic( - GuiActivator.getResources().getI18nMnemonic("service.gui.SEND")); - } - - /** - * Defines actions when send button is pressed. - * - * @param evt The ActionEvent object. - */ - public void actionPerformed(ActionEvent evt) - { - if (!chatPanel.isWriteAreaEmpty()) - { - new Thread() - { - public void run() - { - chatPanel.sendMessage(); - } - }.start(); - } - - //make sure the focus goes back to the write area - chatPanel.requestFocusInWriteArea(); - } - - /** - * Returns the parent ChatPanel. - * @return the parent ChatPanel - */ - public ChatPanel getChatPanel() - { - return chatPanel; - } - - /** - * Returns the main container. Used by the single user chat panel to add - * here the "send via" selector box. - * @return the main container - */ - public JPanel getSendPanel() - { - return sendPanel; - } - - /** - * Returns the status panel contained in this panel. - * @return the status panel contained in this panel - */ - public StatusPanel getStatusPanel() - { - return statusPanel; - } - - /** - * Returns the send button. - * - * @return The send button. - */ - public JButton getSendButton() - { - return sendButton; - } -} diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransportSelectorBox.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransportSelectorBox.java index 2b0dfd040..f04ef9cd0 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransportSelectorBox.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransportSelectorBox.java @@ -12,7 +12,6 @@ import javax.swing.*; -import net.java.sip.communicator.impl.gui.lookandfeel.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.skin.*; @@ -38,36 +37,52 @@ public class ChatTransportSelectorBox private final Map transportMenuItems = new Hashtable(); - private final SIPCommMenu menu = new SIPCommMenu(); + private final SIPCommMenu menu = new SelectorMenu(); private final ChatSession chatSession; + private final ChatPanel chatPanel; + /** * Creates an instance of ChatTransportSelectorBox. * * @param chatSession the corresponding chat session * @param selectedChatTransport the chat transport to select by default */ - public ChatTransportSelectorBox(ChatSession chatSession, + public ChatTransportSelectorBox(ChatPanel chatPanel, + ChatSession chatSession, ChatTransport selectedChatTransport) { + this.chatPanel = chatPanel; this.chatSession = chatSession; - this.menu.setPreferredSize(new Dimension(28, 24)); - this.menu.setUI(new SIPCommSelectorMenuUI()); + setPreferredSize(new Dimension(30, 28)); + setMaximumSize(new Dimension(30, 28)); + setMinimumSize(new Dimension(30, 28)); + + this.menu.setPreferredSize(new Dimension(30, 45)); + this.menu.setMaximumSize(new Dimension(30, 45)); this.add(menu); + this.setBorder(null); + this.menu.setBorder(null); + this.menu.setOpaque(false); + this.setOpaque(false); + // as a default disable the menu, it will be enabled as soon as we add // a valid menu item this.menu.setEnabled(false); - Iterator chatTransports = chatSession.getChatTransports(); + Iterator chatTransports + = chatSession.getChatTransports(); + while (chatTransports.hasNext()) this.addChatTransport(chatTransports.next()); if (this.menu.getItemCount() > 0 && - selectedChatTransport.allowsInstantMessage()) + (selectedChatTransport.allowsInstantMessage() + || selectedChatTransport.allowsSmsMessage())) { this.setSelected(selectedChatTransport); } @@ -90,7 +105,8 @@ private void updateEnableStatus() */ public void addChatTransport(ChatTransport chatTransport) { - if (chatTransport.allowsInstantMessage()) + if (chatTransport.allowsInstantMessage() + || chatTransport.allowsSmsMessage()) { Image img = createTransportStatusImage(chatTransport); @@ -238,6 +254,9 @@ private void setSelected(ChatTransport chatTransport, ImageIcon icon) tooltipText += chatTransport.getDisplayName(); this.menu.setToolTipText(tooltipText); + + chatPanel.getChatWritePanel().setSmsLabelVisible( + chatTransport.allowsSmsMessage()); } /** @@ -278,15 +297,18 @@ private boolean containsOtherOnlineContacts(ChatTransport chatTransport) return false; } - /** - * Reloads UI defs. - */ - public void loadSkin() + private class SelectorMenu extends SIPCommMenu { - super.loadSkin(); + Image image = ImageLoader.getImage(ImageLoader.DOWN_ARROW_ICON); - if(menu != null && menu.getUI() != null - && menu.getUI() instanceof SIPCommSelectorMenuUI) - ((SIPCommSelectorMenuUI) menu.getUI()).loadSkin(); + public void paintComponent(Graphics g) + { + super.paintComponent(g); + + g.drawImage(image, + getWidth() - image.getWidth(this) - 1, + (getHeight() - image.getHeight(this) - 1)/2, + this); + } } } diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java index e3f2943bd..8e603a3dc 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java @@ -148,27 +148,6 @@ public void setToolbarVisible(boolean b) toolbarPanel.setVisible(b); } - /** - * Shows or hides the Stylebar depending on the value of parameter b. - * - * @param b if true, makes the Stylebar visible, otherwise hides the Stylebar - */ - public void setStylebarVisible(boolean b) - { - ChatPanel p = this.getCurrentChat(); - - // Set the value for the current chat panel - if (p != null) - p.setStylebarVisible(b); - - // if there is tabs, set it for all - for (int i = 0, imax = this.getChatTabCount(); i < imax; i++) - { - p = (ChatPanel) this.chatTabbedPane.getComponentAt(i); - p.setStylebarVisible(b); - } - } - /** * @see SIPCommFrame#dispose() */ @@ -427,6 +406,8 @@ public void setCurrentChat(final ChatPanel chatPanel) this.setTitle(chatSession.getChatName()); this.setChatContactPhoto(chatSession); + this.mainToolBar.getSmileysBox().setChat(chatPanel); + chatPanel.requestFocusInWriteArea(); new Thread() @@ -654,8 +635,7 @@ private class OpenSmileyAction { public void actionPerformed(ActionEvent e) { - getCurrentChat().getChatWritePanel() - .getEditTextToolBar().getSmileysSelectorBox().open(); + mainToolBar.getSmileysBox().open(); } } @@ -731,8 +711,7 @@ else if (writePanelRightMenu.isVisible()) writePanelRightMenu.setVisible(false); } else if ((menuBar.getSelectedMenu() != null) - || chatWritePanel - .getEditTextToolBar().hasSelectedMenus()) + || mainToolBar.getSmileysBox().isVisible()) { MenuSelectionManager.defaultManager().clearSelectedPath(); } diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java index 48bc1face..041bd4811 100755 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java @@ -20,7 +20,6 @@ import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.customcontrols.*; import net.java.sip.communicator.impl.gui.main.chat.menus.*; -import net.java.sip.communicator.impl.gui.main.chat.toolBars.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.gui.event.*; @@ -44,13 +43,14 @@ public class ChatWritePanel KeyListener, MouseListener, UndoableEditListener, + DocumentListener, Skinnable { private final Logger logger = Logger.getLogger(ChatWritePanel.class); - private JEditorPane editorPane = new JEditorPane(); + private final JEditorPane editorPane = new JEditorPane(); - private UndoManager undo = new UndoManager(); + private final UndoManager undo = new UndoManager(); private final ChatPanel chatPanel; @@ -60,13 +60,31 @@ public class ChatWritePanel private int typingState = -1; - private WritePanelRightButtonMenu rightButtonMenu; + private final WritePanelRightButtonMenu rightButtonMenu; - private EditTextToolBar editTextToolBar; - - private ArrayList menuListeners + private final ArrayList menuListeners = new ArrayList(); + private final SCScrollPane scrollPane = new SCScrollPane(); + + private ChatTransportSelectorBox transportSelectorBox; + + private final Container centerPanel; + + private JLabel smsLabel; + + private JCheckBoxMenuItem smsMenuItem; + + private JLabel smsCharCountLabel; + + private JLabel smsNumberLabel; + + private int smsNumberCount = 1; + + private int smsCharCount = 160; + + private boolean smsMode = false; + /** * Creates an instance of ChatWritePanel. * @@ -75,44 +93,26 @@ public class ChatWritePanel public ChatWritePanel(ChatPanel panel) { super(new BorderLayout()); - SCScrollPane scrollPane = new SCScrollPane(); this.chatPanel = panel; - this.editorPane.setContentType("text/html"); - - this.editorPane.putClientProperty( - JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); + centerPanel = createCenter(); - this.editorPane.setCaretPosition(0); - this.editorPane.setEditorKit(new SIPCommHTMLEditorKit(this)); - this.editorPane.getDocument().addUndoableEditListener(this); - this.editorPane.addKeyListener(this); - this.editorPane.addMouseListener(this); - this.editorPane.setCursor( - Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); - this.editorPane.setDragEnabled(true); - this.editorPane.setTransferHandler(new ChatTransferHandler(chatPanel)); + int chatAreaSize = ConfigurationManager.getChatWriteAreaSize(); + Dimension writeMessagePanelDefaultSize + = new Dimension(500, (chatAreaSize > 0) ? chatAreaSize : 45); + Dimension writeMessagePanelMinSize = new Dimension(500, 45); + Dimension writeMessagePanelMaxSize = new Dimension(500, 100); - this.editTextToolBar = new EditTextToolBar(this); - this.editTextToolBar.setVisible( - ConfigurationManager.isChatStylebarVisible()); + setMinimumSize(writeMessagePanelMinSize); + setMaximumSize(writeMessagePanelMaxSize); + setPreferredSize(writeMessagePanelDefaultSize); - this.add(editTextToolBar, BorderLayout.NORTH); - this.add(scrollPane, BorderLayout.CENTER); + this.add(centerPanel, BorderLayout.CENTER); this.rightButtonMenu = new WritePanelRightButtonMenu(chatPanel.getChatContainer()); - scrollPane.setHorizontalScrollBarPolicy( - JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); - - scrollPane.setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createMatteBorder(1, 0, 1, 0, Color.GRAY), - BorderFactory.createEmptyBorder(0, 2, 0, 2))); - - scrollPane.setViewportView(editorPane); - this.typingTimer.setRepeats(true); // initialize send command to Ctrl+Enter @@ -133,13 +133,185 @@ public ChatWritePanel(ChatPanel panel) } /** - * Shows or hides the Stylebar depending on the value of parameter b. + * Creates the center panel. * - * @param b if true, makes the Stylebar visible, otherwise hides the Stylebar + * @return the created center panel */ - public void setStylebarVisible(boolean b) + private Container createCenter() { - this.editTextToolBar.setVisible(b); + JPanel centerPanel = new JPanel(new GridBagLayout()); + + centerPanel.setBackground(Color.WHITE); + centerPanel.setBorder(BorderFactory.createEmptyBorder(3, 0, 3, 3)); + + GridBagConstraints constraints = new GridBagConstraints(); + + initSmsLabel(centerPanel); + initTextArea(centerPanel); + + smsCharCountLabel = new JLabel(String.valueOf(smsCharCount)); + smsCharCountLabel.setForeground(Color.GRAY); + smsCharCountLabel.setVisible(false); + + constraints.anchor = GridBagConstraints.NORTHEAST; + constraints.fill = GridBagConstraints.NONE; + constraints.gridx = 3; + constraints.gridy = 0; + constraints.weightx = 0f; + constraints.weighty = 0f; + constraints.insets = new Insets(0, 2, 0, 2); + constraints.gridheight = 1; + constraints.gridwidth = 1; + centerPanel.add(smsCharCountLabel, constraints); + + smsNumberLabel = new JLabel(String.valueOf(smsNumberCount)) + { + public void paintComponent(Graphics g) + { + AntialiasingManager.activateAntialiasing(g); + g.setColor(getBackground()); + g.fillOval(0, 0, getWidth(), getHeight()); + + super.paintComponent(g); + } + }; + smsNumberLabel.setHorizontalAlignment(JLabel.CENTER); + smsNumberLabel.setPreferredSize(new Dimension(18, 18)); + smsNumberLabel.setMinimumSize(new Dimension(18, 18)); + smsNumberLabel.setForeground(Color.WHITE); + smsNumberLabel.setBackground(Color.GRAY); + smsNumberLabel.setVisible(false); + + constraints.anchor = GridBagConstraints.NORTHEAST; + constraints.fill = GridBagConstraints.NONE; + constraints.gridx = 4; + constraints.gridy = 0; + constraints.weightx = 0f; + constraints.weighty = 0f; + constraints.insets = new Insets(0, 2, 0, 2); + constraints.gridheight = 1; + constraints.gridwidth = 1; + centerPanel.add(smsNumberLabel, constraints); + + return centerPanel; + } + + /** + * Initializes the sms menu. + * + * @param centerPanel the parent panel + */ + private void initSmsLabel(final JPanel centerPanel) + { + GridBagConstraints constraints = new GridBagConstraints(); + + constraints.anchor = GridBagConstraints.NORTHWEST; + constraints.fill = GridBagConstraints.NONE; + constraints.gridx = 1; + constraints.gridy = 0; + constraints.gridheight = 1; + constraints.weightx = 0f; + constraints.weighty = 0f; + constraints.insets = new Insets(0, 3, 0, 0); + + final Icon smsIcon = GuiActivator.getResources() + .getImage("service.gui.icons.SEND_SMS"); + + final Icon selectedIcon = GuiActivator.getResources() + .getImage("service.gui.icons.SEND_SMS_SELECTED"); + + smsLabel = new JLabel(smsIcon); + smsLabel.setVisible(true); + + smsMenuItem = new JCheckBoxMenuItem(GuiActivator.getResources() + .getI18NString("service.gui.VIA_SMS")); + + smsMenuItem.addChangeListener(new ChangeListener() + { + public void stateChanged(ChangeEvent e) + { + smsMode = smsMenuItem.isSelected(); + + Color bgColor; + if (smsMode) + { + smsLabel.setIcon(selectedIcon); + bgColor = new Color(GuiActivator.getResources() + .getColor("service.gui.LIST_SELECTION_COLOR")); + } + else + { + smsLabel.setIcon(smsIcon); + bgColor = Color.WHITE; + } + + centerPanel.setBackground(bgColor); + editorPane.setBackground(bgColor); + + smsLabel.repaint(); + } + }); + + smsLabel.addMouseListener(new MouseAdapter() + { + public void mousePressed(MouseEvent mouseevent) + { + Point location = new Point(smsLabel.getX(), + smsLabel.getY() + smsLabel.getHeight()); + + SwingUtilities.convertPointToScreen(location, smsLabel); + + JPopupMenu smsPopupMenu = new JPopupMenu(); + smsPopupMenu.setFocusable(true); + smsPopupMenu.setInvoker(ChatWritePanel.this); + smsPopupMenu.add(smsMenuItem); + smsPopupMenu.setLocation(location.x, location.y); + smsPopupMenu.setVisible(true); + } + }); + + centerPanel.add(smsLabel, constraints); + } + + private void initTextArea(JPanel centerPanel) + { + GridBagConstraints constraints = new GridBagConstraints(); + + editorPane.setContentType("text/html"); + editorPane.putClientProperty( + JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); + editorPane.setCaretPosition(0); + editorPane.setEditorKit(new SIPCommHTMLEditorKit(this)); + editorPane.getDocument().addUndoableEditListener(this); + editorPane.getDocument().addDocumentListener(this); + editorPane.addKeyListener(this); + editorPane.addMouseListener(this); + editorPane.setCursor( + Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); + editorPane.setDragEnabled(true); + editorPane.setTransferHandler(new ChatTransferHandler(chatPanel)); + + scrollPane.setHorizontalScrollBarPolicy( + JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + scrollPane.setVerticalScrollBarPolicy( + JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); + + scrollPane.setOpaque(false); + scrollPane.getViewport().setOpaque(false); + scrollPane.setBorder(null); + + scrollPane.setViewportView(editorPane); + + constraints.anchor = GridBagConstraints.NORTHWEST; + constraints.fill = GridBagConstraints.BOTH; + constraints.gridx = 2; + constraints.gridy = 0; + constraints.weightx = 1f; + constraints.weighty = 1f; + constraints.gridheight = 1; + constraints.gridwidth = 1; + constraints.insets = new Insets(0, 0, 0, 0); + centerPanel.add(scrollPane, constraints); } /** @@ -195,7 +367,7 @@ public void changeSendCommand(boolean isEnter) im.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.SHIFT_DOWN_MASK), "newLine"); - chatPanel.getChatSendPanel().getSendButton().setToolTipText( + this.setToolTipText( "" + GuiActivator.getResources() .getI18NString("service.gui.SEND_MESSAGE") @@ -209,14 +381,35 @@ public void changeSendCommand(boolean isEnter) KeyEvent.CTRL_DOWN_MASK), "send"); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "newLine"); - chatPanel.getChatSendPanel().getSendButton() - .setToolTipText( + this.setToolTipText( GuiActivator.getResources() .getI18NString("service.gui.SEND_MESSAGE") + " Ctrl-Enter"); } } + /** + * Enables/disables the sms mode. + * + * @param selected true to enable sms mode, false - + * otherwise + */ + public void setSmsSelected(boolean selected) + { + smsMenuItem.setSelected(selected); + } + + /** + * Returns true if the sms mode is enabled, otherwise returns + * false. + * @return true if the sms mode is enabled, otherwise returns + * false + */ + public boolean isSmsSelected() + { + return smsMode; + } + /** * The SendMessageAction is an AbstractAction that * sends the text that is currently in the write message area. @@ -556,13 +749,231 @@ private String extractFormattedText(String msgText) } /** - * Returns the toolbar above the chat write area. + * Initializes the send via label and selector box. + * + * @return the chat transport selector box + */ + private Component createChatTransportSelectorBox() + { + // Initialize the "send via" selector box and adds it to the send panel. + if (transportSelectorBox == null) + { + transportSelectorBox = new ChatTransportSelectorBox( + chatPanel, + chatPanel.getChatSession(), + chatPanel.getChatSession().getCurrentChatTransport()); + } + + return transportSelectorBox; + } + + /** + * + * @param isVisible + */ + public void setTransportSelectorBoxVisible(boolean isVisible) + { + if (isVisible) + { + if (transportSelectorBox == null) + { + createChatTransportSelectorBox(); + + if (!transportSelectorBox.getMenu().isEnabled()) + { + // Show a message to the user that IM is not possible. + chatPanel.getChatConversationPanel() + .appendMessageToEnd("
" + + GuiActivator.getResources(). + getI18NString("service.gui.MSG_NOT_POSSIBLE") + + "
"); + } + else + { + GridBagConstraints constraints = new GridBagConstraints(); + constraints.anchor = GridBagConstraints.NORTHEAST; + constraints.fill = GridBagConstraints.NONE; + constraints.gridx = 0; + constraints.gridy = 0; + constraints.weightx = 0f; + constraints.weighty = 0f; + constraints.gridheight = 1; + constraints.gridwidth = 1; + + centerPanel.add(transportSelectorBox, constraints, 0); + } + } + else + { + transportSelectorBox.setVisible(true); + centerPanel.repaint(); + } + } + else if (transportSelectorBox != null) + { + transportSelectorBox.setVisible(false); + centerPanel.repaint(); + } + } + + /** + * Selects the given chat transport in the send via box. + * + * @param chatTransport the chat transport to be selected + */ + public void setSelectedChatTransport(ChatTransport chatTransport) + { + if (transportSelectorBox != null) + { + transportSelectorBox.setSelected(chatTransport); + } + } + + /** + * Adds the given chatTransport to the given send via selector box. * - * @return the toolbar above the chat write area. + * @param chatTransport the transport to add */ - public EditTextToolBar getEditTextToolBar() + public void addChatTransport(ChatTransport chatTransport) { - return editTextToolBar; + if (transportSelectorBox != null) + transportSelectorBox.addChatTransport(chatTransport); + } + + /** + * Updates the status of the given chat transport in the send via selector + * box and notifies the user for the status change. + * @param chatTransport the chatTransport to update + */ + public void updateChatTransportStatus(ChatTransport chatTransport) + { + if (transportSelectorBox != null) + transportSelectorBox.updateTransportStatus(chatTransport); + } + + /** + * Opens the selector box containing the protocol contact icons. + * This is the menu, where user could select the protocol specific + * contact to communicate through. + */ + public void openChatTransportSelectorBox() + { + transportSelectorBox.getMenu().doClick(); + } + + /** + * Removes the given chat status state from the send via selector box. + * + * @param chatTransport the transport to remove + */ + public void removeChatTransport(ChatTransport chatTransport) + { + if (transportSelectorBox != null) + transportSelectorBox.removeChatTransport(chatTransport); + } + + /** + * Show the sms menu. + * @param isVisible true to show the sms menu, false - + * otherwise + */ + public void setSmsLabelVisible(boolean isVisible) + { + // Re-init sms count properties. + smsCharCount = 160; + smsNumberCount = 1; + + smsLabel.setVisible(isVisible); + smsCharCountLabel.setVisible(isVisible); + smsNumberLabel.setVisible(isVisible); + + centerPanel.repaint(); + } + + /** + * Sets the font family and size + * @param family the family name + * @param size the size + */ + public void setFontFamilyAndSize(String family, int size) + { + // Family + ActionEvent evt + = new ActionEvent( editorPane, + ActionEvent.ACTION_PERFORMED, + family); + Action action = new StyledEditorKit.FontFamilyAction(family, family); + action.actionPerformed(evt); + + // Size + evt = new ActionEvent(editorPane, + ActionEvent.ACTION_PERFORMED, Integer.toString(size)); + action = new StyledEditorKit.FontSizeAction(Integer.toString(size), size); + action.actionPerformed(evt); + } + + /** + * Enables the bold style + * @param b TRUE enable - FALSE disable + */ + public void setBoldStyleEnable(boolean b) + { + if (b) + { + setStyleConstant( new HTMLEditorKit.BoldAction(), + StyleConstants.Bold); + } + } + + /** + * Enables the italic style + * @param b TRUE enable - FALSE disable + */ + public void setItalicStyleEnable(boolean b) + { + if (b) + { + setStyleConstant( new HTMLEditorKit.ItalicAction(), + StyleConstants.Italic); + } + } + + /** + * Enables the underline style + * @param b TRUE enable - FALSE disable + */ + public void setUnderlineStyleEnable(boolean b) + { + if (b) + { + setStyleConstant( new HTMLEditorKit.UnderlineAction(), + StyleConstants.Underline); + } + } + + /** + * Sets the font color + * @param color the color + */ + public void setFontColor(Color color) + { + ActionEvent evt + = new ActionEvent(editorPane, ActionEvent.ACTION_PERFORMED, ""); + Action action + = new HTMLEditorKit.ForegroundAction( + Integer.toString(color.getRGB()), + color); + + action.actionPerformed(evt); + } + + private void setStyleConstant(Action action, Object styleConstant) + { + ActionEvent event = new ActionEvent(editorPane, + ActionEvent.ACTION_PERFORMED, + styleConstant.toString()); + + action.actionPerformed(event); } /** @@ -596,4 +1007,54 @@ public void loadSkin() { getRightButtonMenu().loadSkin(); } + + public void changedUpdate(DocumentEvent documentevent) {} + + /** + * Updates write panel size and adjusts sms properties if the sms menu + * is visible. + * + * @param event the DocumentEvent that notified us + */ + public void insertUpdate(DocumentEvent event) + { + // If we're in sms mode count the chars typed. + if (smsLabel.isVisible()) + { + if (smsCharCount == 0) + { + smsCharCount = 159; + smsNumberCount ++; + } + else + smsCharCount--; + + smsCharCountLabel.setText(String.valueOf(smsCharCount)); + smsNumberLabel.setText(String.valueOf(smsNumberCount)); + } + } + + /** + * Updates write panel size and adjusts sms properties if the sms menu + * is visible. + * + * @param event the DocumentEvent that notified us + */ + public void removeUpdate(DocumentEvent event) + { + // If we're in sms mode count the chars typed. + if (smsLabel.isVisible()) + { + if (smsCharCount == 160 && smsNumberCount > 1) + { + smsCharCount = 0; + smsNumberCount --; + } + else + smsCharCount++; + + smsCharCountLabel.setText(String.valueOf(smsCharCount)); + smsNumberLabel.setText(String.valueOf(smsNumberCount)); + } + } } 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 a53883353..89c6b0c2f 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 @@ -37,7 +37,7 @@ public class SmileysSelectorBox /** * The chat write panel. */ - private final ChatWritePanel chatWritePanel; + private ChatPanel chatPanel; /** * The smiley text label. @@ -61,14 +61,9 @@ public class SmileysSelectorBox /** * Initializes a new SmileysSelectorBox instance. - * - * @param writePanel the ChatWritePanel the new instance is to - * write the selected Smiley into when it is clicked */ - public SmileysSelectorBox(ChatWritePanel writePanel) + public SmileysSelectorBox() { - this.chatWritePanel = writePanel; - this.setOpaque(false); // Should explicitly remove any border in order to align correctly the // icon. @@ -90,6 +85,16 @@ public SmileysSelectorBox(ChatWritePanel writePanel) this.smiliesService = GuiActivator.getSmiliesReplacementSource(); } + /** + * Sets the chat panel, for which smilieys would be created. + * + * @param chatPanel the chat panel, for which smilieys would be created + */ + public void setChat(ChatPanel chatPanel) + { + this.chatPanel = chatPanel; + } + /** * In order to have a popup which is at the form closest to square. * @@ -139,9 +144,9 @@ public void actionPerformed(ActionEvent e) SmileyMenuItem smileyItem = (SmileyMenuItem) e.getSource(); Smiley smiley = smileyItem.smiley; - chatWritePanel.appendText(smiley.getDefaultString()); + chatPanel.getChatWritePanel().appendText(smiley.getDefaultString()); - chatWritePanel.getEditorPane().requestFocus(); + chatPanel.getChatWritePanel().getEditorPane().requestFocus(); clearMouseOverEffects(smileyItem); } 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 417793391..37b9c984b 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 @@ -341,7 +341,7 @@ else if (o instanceof FileRecord) /** * Implements ChatConversationContainer.setStatusMessage method. */ - public void setStatusMessage(String message) {} + public void addTypingNotification(String message) {} /** * Implements ChatConversationContainer.getWindow method. 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 f6eba94ca..a3dc66e78 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 @@ -120,8 +120,7 @@ else if (menuItemName.equalsIgnoreCase("paste")) } else if (menuItemName.equalsIgnoreCase("font")) { - this.chatWindow.getCurrentChat().getChatWritePanel() - .getEditTextToolBar().showFontChooserDialog(); + this.chatWindow.getCurrentChat().showFontChooserDialog(); } } 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 05c4be19c..aef7a6a91 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 @@ -31,10 +31,6 @@ public class OptionsMenu GuiActivator.getResources().getI18NString("service.gui.VIEW_TOOLBAR")); private static final String ACTCMD_VIEW_TOOLBAR = "ACTCMD_VIEW_TOOLBAR"; - private JCheckBoxMenuItem viewStyleBar = new JCheckBoxMenuItem( - GuiActivator.getResources().getI18NString("service.gui.VIEW_STYLEBAR")); - private static final String ACTCMD_VIEW_STYLEBAR = "ACTCMD_VIEW_STYLEBAR"; - private JCheckBoxMenuItem viewSmileys = new JCheckBoxMenuItem( GuiActivator.getResources().getI18NString("service.gui.VIEW_SMILEYS")); private static final String ACTCMD_VIEW_SMILEYS = "ACTCMD_VIEW_SMILEYS"; @@ -55,10 +51,6 @@ public OptionsMenu(ChatWindow chatWindow) this.viewToolBar.addActionListener(this); this.add(this.viewToolBar); - this.viewStyleBar.setActionCommand(ACTCMD_VIEW_STYLEBAR); - this.viewStyleBar.addActionListener(this); - this.add(this.viewStyleBar); - this.viewSmileys.setActionCommand(ACTCMD_VIEW_SMILEYS); this.viewSmileys.addActionListener(this); this.add(this.viewSmileys); @@ -73,8 +65,7 @@ private void initValues() { this.viewToolBar.setSelected( ConfigurationManager.isChatToolbarVisible()); - this.viewStyleBar.setSelected( - ConfigurationManager.isChatStylebarVisible()); + this.viewSmileys.setSelected( ConfigurationManager.isShowSmileys()); } @@ -94,12 +85,6 @@ public void actionPerformed(ActionEvent e) ConfigurationManager .setChatToolbarVisible(viewToolBar.isSelected()); } - else if (action.equals(ACTCMD_VIEW_STYLEBAR)) - { - this.chatWindow.setStylebarVisible(viewStyleBar.isSelected()); - ConfigurationManager - .setChatStylebarVisible(viewStyleBar.isSelected()); - } else if (action.equals(ACTCMD_VIEW_SMILEYS)) { ConfigurationManager.setShowSmileys(viewSmileys.isSelected()); 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 deleted file mode 100644 index 2818ed5e2..000000000 --- a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/EditTextToolBar.java +++ /dev/null @@ -1,608 +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.main.chat.toolBars; - -import java.awt.*; -import java.awt.event.*; - -import javax.swing.*; -import javax.swing.event.*; -import javax.swing.text.*; -import javax.swing.text.html.*; - -import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.impl.gui.main.chat.*; -import net.java.sip.communicator.impl.gui.utils.*; -import net.java.sip.communicator.util.skin.*; -import net.java.sip.communicator.util.swing.*; - -/** - * The EditTextToolBar is a JToolBar which contains - * buttons for formatting a text, like make text in bold or italic, change the - * font, etc. It contains only MsgToolbarButtons, which have a - * specific background icon and rollover behaviour to differentiates them from - * normal buttons. - * - * @author Yana Stamcheva - * @author Lubomir Marinov - * @author Adam Netocny - */ -public class EditTextToolBar - extends TransparentPanel - implements Skinnable -{ - private final ChatWritePanel chatWritePanel; - - private final JEditorPane chatEditorPane; - - private final SmileysSelectorBox smileysBox; - - private JToggleButton boldButton; - - private JToggleButton italicButton; - - private JToggleButton underlineButton; - - private ColorLabel colorLabel; - - private SIPCommButton fontButton; - - /** - * Creates an instance and constructs the EditTextToolBar. - * @param writePanel the panel containing the chat write area - */ - public EditTextToolBar(ChatWritePanel writePanel) - { - this.chatWritePanel = writePanel; - this.chatEditorPane = writePanel.getEditorPane(); - - this.setOpaque(false); - this.setLayout(new FlowLayout(FlowLayout.LEFT, 2, 0)); - - this.initStyleToolbarButtons(); - - fontButton - = new SIPCommButton( - ImageLoader.getImage(ImageLoader.EDIT_TOOLBAR_BUTTON), - ImageLoader.getImage(ImageLoader.FONT_ICON)); - fontButton.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent event) - { - showFontChooserDialog(); - } - }); - this.add(fontButton); - - this.initColorLabel(); - - this.smileysBox = new SmileysSelectorBox(chatWritePanel); - - this.smileysBox.setName("smiley"); - this.smileysBox.setToolTipText(GuiActivator.getResources() - .getI18NString("service.gui.INSERT_SMILEY") + " Ctrl-M"); - - SIPCommMenuBar smileyMenuBar = new SIPCommMenuBar(); - smileyMenuBar.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); - smileyMenuBar.add(smileysBox); - - this.add(smileyMenuBar); - } - - /** - * Initializes the label that changes font color. - */ - private void initColorLabel() - { - this.colorLabel = new ColorLabel(); - colorLabel.setPreferredSize(new Dimension(18, 18)); - - colorLabel.setOpaque(true); - colorLabel.setBackground(Color.BLACK); - - this.add(colorLabel); - - colorLabel.addMouseListener(new MouseAdapter() - { - @Override - public void mousePressed(MouseEvent event) - { - Color newColor = - JColorChooser.showDialog(new JColorChooser(), - "Choose a colour", - colorLabel.getBackground()); - - if (newColor != null) - setFontColor(newColor); - - chatEditorPane.requestFocus(); - } - }); - - chatEditorPane.addCaretListener(new CaretListener() - { - public void caretUpdate(CaretEvent e) - { - selectColor(StyleConstants.Foreground, colorLabel); - } - }); - - chatEditorPane.addKeyListener(new KeyAdapter() - { - @Override - public void keyTyped(KeyEvent e) - { - String chatWritePanelText = chatWritePanel.getText(); - if (chatWritePanelText != null && - chatWritePanelText.length() > 0) - { - Color currentColor - = (Color) ((HTMLEditorKit) chatEditorPane - .getEditorKit()).getInputAttributes().getAttribute( - StyleConstants.Foreground); - - if (currentColor != null) - colorLabel.setBackground(currentColor); - else - colorLabel.setBackground(Color.BLACK); - } - } - }); - - chatEditorPane.addMouseListener(new MouseAdapter() - { - @Override - public void mouseClicked(MouseEvent e) - { - selectColor(StyleConstants.Foreground, colorLabel); - } - }); - } - - /** - * Initializes Bold, Italic and Underline toggle buttons. - */ - private void initStyleToolbarButtons() - { - this.boldButton - = initStyleToggleButton( - ImageLoader.getImage(ImageLoader.TEXT_BOLD_BUTTON), - new HTMLEditorKit.BoldAction(), - StyleConstants.Bold); - this.italicButton - = initStyleToggleButton( - ImageLoader.getImage(ImageLoader.TEXT_ITALIC_BUTTON), - new HTMLEditorKit.ItalicAction(), - StyleConstants.Italic); - this.underlineButton - = initStyleToggleButton( - ImageLoader.getImage(ImageLoader.TEXT_UNDERLINED_BUTTON), - new HTMLEditorKit.UnderlineAction(), - StyleConstants.Underline); - - /* - * The update of the style toggle buttons used to be very slow because - * each of it had to retrieve the same data on its own (most notably, - * JEditorPane#getText()) and make almost the same checks. That is why - * the update logic is performed for all of them, not individually i.e. - * the data is retrieved once, the checks are made and all style toggle - * buttons are updated. - */ - final Object[] styleConstants - = new Object[] - { - StyleConstants.Bold, - StyleConstants.Italic, - StyleConstants.Underline - }; - final JToggleButton[] buttons - = new JToggleButton[] - { - boldButton, - italicButton, - underlineButton - }; - - chatEditorPane.addCaretListener(new CaretListener() - { - public void caretUpdate(CaretEvent e) - { - selectStyleToggleButtons(styleConstants, buttons); - } - }); - chatEditorPane.addKeyListener(new KeyAdapter() - { - @Override - public void keyTyped(KeyEvent e) - { - if (chatEditorPane.getText().length() > 0) - { - AttributeSet attributes - = ((HTMLEditorKit) chatEditorPane.getEditorKit()) - .getInputAttributes(); - - for (int i = 0; i < buttons.length; i++) - buttons[i] - .setSelected( - attributes - .containsAttribute( - styleConstants[i], - true)); - } - } - }); - chatEditorPane.addMouseListener(new MouseAdapter() - { - @Override - public void mouseClicked(MouseEvent e) - { - selectStyleToggleButtons(styleConstants, buttons); - } - }); - - this.addBindings(); - } - - /** - * Initializes a toggle button. - * - * @param buttonImage the Image to be used as the icon of the new - * button - * @param action the action to associate with the button - * @param styleConstant the style constant - * @return the toggle button with the associated action and style constant - */ - private JToggleButton initStyleToggleButton(Image buttonImage, - final Action action, - final Object styleConstant) - { - final SIPCommToggleButton button - = new SIPCommToggleButton( - ImageLoader.getImage(ImageLoader.EDIT_TOOLBAR_BUTTON), - ImageLoader.getImage(ImageLoader.EDIT_TOOLBAR_BUTTON), - buttonImage, - ImageLoader.getImage(ImageLoader.EDIT_TOOLBAR_BUTTON_PRESSED)); - - button.setPreferredSize(new Dimension(18, 18)); - button.setName(styleConstant.toString()); - button.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - ActionEvent event = new ActionEvent(chatEditorPane, - ActionEvent.ACTION_PERFORMED, - styleConstant.toString()); - - action.actionPerformed(event); - - chatEditorPane.requestFocus(); - } - }); - - add(button); - return button; - } - - /** - * Selects or deselects the given toggle buttons depending on the given - * styleConstants. - * - * @param styleConstants the style constants - * @param buttons the buttons to select - */ - private void selectStyleToggleButtons( - Object[] styleConstants, - JToggleButton[] buttons) - { - if (chatEditorPane.getText().length() < 1) - return; - - if (chatEditorPane.getSelectedText() == null) - { - AttributeSet attributes - = ((HTMLDocument) chatEditorPane.getDocument()) - .getCharacterElement(chatEditorPane.getCaretPosition() - 1) - .getAttributes(); - - for (int i = 0; i < buttons.length; i++) - buttons[i] - .setSelected( - attributes.containsAttribute(styleConstants[i], true)); - } - else - { - int selectionStart = chatEditorPane.getSelectionStart(); - int selectionEnd = chatEditorPane.getSelectionEnd(); - HTMLDocument htmlDocument - = (HTMLDocument) chatEditorPane.getDocument(); - - for (int buttonIndex = 0; - buttonIndex < buttons.length; - buttonIndex++) - { - boolean selected = false; - Object styleConstant = styleConstants[buttonIndex]; - - for (int selectionIndex = selectionStart; - selectionIndex < selectionEnd; - selectionIndex++) - { - AttributeSet attributes - = htmlDocument - .getCharacterElement(selectionIndex) - .getAttributes(); - - selected - = attributes.containsAttribute(styleConstant, true); - if (selected) - break; - } - - buttons[buttonIndex].setSelected(selected); - } - } - } - - /** - * Selects the color corresponding to the current style attribute. - * - * @param styleConstant the style constant - * @param colorLabel the color label to select the color from - */ - private void selectColor( final Object styleConstant, - final JLabel colorLabel) - { - Object selectedAttribute = null; - - if (chatEditorPane.getSelectedText() == null) - { - int index = chatEditorPane.getCaretPosition(); - selectedAttribute = - ((HTMLDocument) chatEditorPane.getDocument()) - .getCharacterElement(index - 1).getAttributes() - .getAttribute(styleConstant); - } - else - { - for (int index = chatEditorPane.getSelectionStart(); - index < chatEditorPane.getSelectionEnd(); index++) - { - AttributeSet attributes = - ((HTMLDocument) chatEditorPane.getDocument()) - .getCharacterElement(index).getAttributes(); - - if (attributes.getAttribute(styleConstant) != null) - selectedAttribute = attributes.getAttribute(styleConstant); - } - } - - if (selectedAttribute != null) - colorLabel.setBackground((Color)selectedAttribute); - else - colorLabel.setBackground(Color.BLACK); - } - - /** - * Adds key bindings for formatting actions. - */ - private void addBindings() - { - InputMap inputMap = chatEditorPane.getInputMap(); - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, - Event.SHIFT_MASK), DefaultEditorKit.deletePrevCharAction); - - // styles - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_B, Event.CTRL_MASK), - "font-bold"); //$NON-NLS-1$ - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F, Event.CTRL_MASK), - "font-bold"); //$NON-NLS-1$ - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.CTRL_MASK), - "font-italic"); //$NON-NLS-1$ - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_K, Event.CTRL_MASK), - "font-italic"); //$NON-NLS-1$ - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_U, Event.CTRL_MASK), - "font-underline"); //$NON-NLS-1$ - } - - private static class ColorLabel extends JLabel - { - @Override - public void paintComponent(Graphics g) - { - g = g.create(); - try - { - AntialiasingManager.activateAntialiasing(g); - - g.setColor(this.getBackground()); - g.fillRoundRect(0, 0, getWidth(), getHeight(), 8, 8); - } - finally - { - g.dispose(); - } - } - } - - /** - * Shows the font chooser dialog - */ - public void showFontChooserDialog() - { - FontChooser fontChooser = new FontChooser(); - - fontChooser.setFontFamily( - chatEditorPane.getFont().getFontName()); - fontChooser.setFontSize( - chatEditorPane.getFont().getSize()); - - fontChooser.setBoldStyle(boldButton.isSelected()); - fontChooser.setItalicStyle(italicButton.isSelected()); - fontChooser.setUnderlineStyle(underlineButton.isSelected()); - - int result = fontChooser.showDialog(this.chatWritePanel); - - if (result == FontChooser.OK_OPTION) - { - // Font family and size - setFontFamilyAndSize( fontChooser.getFontFamily(), - fontChooser.getFontSize()); - - // Font style - setBoldStyleEnable(fontChooser.isBoldStyleSelected()); - setItalicStyleEnable(fontChooser.isItalicStyleSelected()); - setUnderlineStyleEnable(fontChooser.isUnderlineStyleSelected()); - - // Font color - setFontColor(fontChooser.getFontColor()); - } - - chatEditorPane.requestFocus(); - } - - /** - * Sets the font family and size - * @param family the family name - * @param size the size - */ - public void setFontFamilyAndSize(String family, int size) - { - // Family - ActionEvent evt - = new ActionEvent( chatEditorPane, - ActionEvent.ACTION_PERFORMED, - family); - Action action = new StyledEditorKit.FontFamilyAction(family, family); - action.actionPerformed(evt); - - // Size - evt = new ActionEvent(chatEditorPane, - ActionEvent.ACTION_PERFORMED, Integer.toString(size)); - action = new StyledEditorKit.FontSizeAction(Integer.toString(size), size); - action.actionPerformed(evt); - } - - /** - * Enables the bold style - * @param b TRUE enable - FALSE disable - */ - public void setBoldStyleEnable(boolean b) - { - if ((b && !boldButton.isSelected()) || (!b && boldButton.isSelected())) - boldButton.doClick(); - } - - /** - * Enables the italic style - * @param b TRUE enable - FALSE disable - */ - public void setItalicStyleEnable(boolean b) - { - if ((b && !italicButton.isSelected()) - || (!b && italicButton.isSelected())) - italicButton.doClick(); - } - - /** - * Enables the underline style - * @param b TRUE enable - FALSE disable - */ - public void setUnderlineStyleEnable(boolean b) - { - if ((b && !underlineButton.isSelected()) - || (!b && underlineButton.isSelected())) - underlineButton.doClick(); - } - - /** - * Sets the font color - * @param color the color - */ - public void setFontColor(Color color) - { - colorLabel.setBackground(color); - - ActionEvent evt - = new ActionEvent(chatEditorPane, ActionEvent.ACTION_PERFORMED, ""); - Action action - = new HTMLEditorKit.ForegroundAction( - Integer.toString(color.getRGB()), - color); - - action.actionPerformed(evt); - } - - /** - * Returns the button used to show the list of smileys. - * - * @return the button used to show the list of smileys. - */ - public SmileysSelectorBox getSmileysSelectorBox() - { - return smileysBox; - } - - /** - * Returns TRUE if there are selected menus in this toolbar, otherwise - * returns FALSE. - * @return TRUE if there are selected menus in this toolbar, otherwise - * returns FALSE - */ - public boolean hasSelectedMenus() - { - return smileysBox.isMenuSelected(); - } - - /** - * Loads the skin. - */ - public void loadSkin() - { - fontButton.setBackgroundImage( - ImageLoader.getImage(ImageLoader.EDIT_TOOLBAR_BUTTON)); - fontButton.setIconImage( - ImageLoader.getImage(ImageLoader.FONT_ICON)); - - ((SIPCommToggleButton)this.boldButton).setBgImage( - new ImageIcon(ImageLoader.getImage( - ImageLoader.EDIT_TOOLBAR_BUTTON)).getImage()); - ((SIPCommToggleButton)this.boldButton).setBgRolloverImage( - new ImageIcon(ImageLoader.getImage( - ImageLoader.EDIT_TOOLBAR_BUTTON)).getImage()); - ((SIPCommToggleButton)this.boldButton).setIconImage( - new ImageIcon(ImageLoader.getImage( - ImageLoader.TEXT_BOLD_BUTTON)).getImage()); - ((SIPCommToggleButton)this.boldButton).setPressedImage( - new ImageIcon(ImageLoader.getImage( - ImageLoader.EDIT_TOOLBAR_BUTTON_PRESSED)).getImage()); - - ((SIPCommToggleButton)this.italicButton).setBgImage( - new ImageIcon(ImageLoader.getImage( - ImageLoader.EDIT_TOOLBAR_BUTTON)).getImage()); - ((SIPCommToggleButton)this.italicButton).setBgRolloverImage( - new ImageIcon(ImageLoader.getImage( - ImageLoader.EDIT_TOOLBAR_BUTTON)).getImage()); - ((SIPCommToggleButton)this.italicButton).setIconImage( - new ImageIcon(ImageLoader.getImage( - ImageLoader.TEXT_ITALIC_BUTTON)).getImage()); - ((SIPCommToggleButton)this.italicButton).setPressedImage( - new ImageIcon(ImageLoader.getImage( - ImageLoader.EDIT_TOOLBAR_BUTTON_PRESSED)).getImage()); - - ((SIPCommToggleButton)this.underlineButton).setBgImage( - new ImageIcon(ImageLoader.getImage( - ImageLoader.EDIT_TOOLBAR_BUTTON)).getImage()); - ((SIPCommToggleButton)this.underlineButton).setBgRolloverImage( - new ImageIcon(ImageLoader.getImage( - ImageLoader.EDIT_TOOLBAR_BUTTON)).getImage()); - ((SIPCommToggleButton)this.underlineButton).setIconImage( - new ImageIcon(ImageLoader.getImage( - ImageLoader.TEXT_UNDERLINED_BUTTON)).getImage()); - ((SIPCommToggleButton)this.underlineButton).setPressedImage( - new ImageIcon(ImageLoader.getImage( - ImageLoader.EDIT_TOOLBAR_BUTTON_PRESSED)).getImage()); - } -} diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java index 64399a0f2..33db5647f 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java @@ -115,6 +115,15 @@ public class MainToolBar = new ChatToolbarButton( ImageLoader.getImage(ImageLoader.CHAT_DESKTOP_SHARING)); + /** + * The font button. + */ + private final ChatToolbarButton fontButton + = new ChatToolbarButton( + ImageLoader.getImage(ImageLoader.FONT_ICON)); + + private SmileysSelectorBox smileysBox; + /** * The current ChatSession made known to this instance by the last * call to its {@link #chatChanged(ChatPanel)}. @@ -166,24 +175,32 @@ protected void init() this.add(callButton); this.add(desktopSharingButton); + this.add(sendFileButton); + + this.addSeparator(); + this.add(historyButton); + this.add(previousButton); + this.add(nextButton); // We only add the options button if the property SHOW_OPTIONS_WINDOW // specifies so or if it's not set. Boolean showOptionsProp = GuiActivator.getConfigurationService() .getBoolean(ConfigurationFrame.SHOW_OPTIONS_WINDOW_PROPERTY, - true); + false); if (showOptionsProp.booleanValue()) { this.add(optionsButton); } - this.add(sendFileButton); + this.addSeparator(); - this.add(previousButton); - this.add(nextButton); + this.add(fontButton); + initSmiliesSelectorBox(); + + this.addSeparator(); this.inviteButton.setName("invite"); this.inviteButton.setToolTipText( @@ -212,6 +229,10 @@ protected void init() optionsButton.setToolTipText( GuiActivator.getResources().getI18NString("service.gui.OPTIONS")); + fontButton.setName("font"); + fontButton.setToolTipText( + GuiActivator.getResources().getI18NString("service.gui.CHANGE_FONT")); + this.sendFileButton.setName("sendFile"); this.sendFileButton.setToolTipText( GuiActivator.getResources().getI18NString("service.gui.SEND_FILE")); @@ -224,15 +245,31 @@ protected void init() this.nextButton.setToolTipText( GuiActivator.getResources().getI18NString("service.gui.NEXT")); - this.inviteButton.addActionListener(this); - this.leaveChatRoomButton.addActionListener(this); - this.callButton.addActionListener(this); - this.desktopSharingButton.addActionListener(this); - this.historyButton.addActionListener(this); + inviteButton.addActionListener(this); + leaveChatRoomButton.addActionListener(this); + callButton.addActionListener(this); + desktopSharingButton.addActionListener(this); + historyButton.addActionListener(this); optionsButton.addActionListener(this); - this.sendFileButton.addActionListener(this); - this.previousButton.addActionListener(this); - this.nextButton.addActionListener(this); + fontButton.addActionListener(this); + sendFileButton.addActionListener(this); + previousButton.addActionListener(this); + nextButton.addActionListener(this); + } + + private void initSmiliesSelectorBox() + { + this.smileysBox = new SmileysSelectorBox(); + + this.smileysBox.setName("smiley"); + this.smileysBox.setToolTipText(GuiActivator.getResources() + .getI18NString("service.gui.INSERT_SMILEY") + " Ctrl-M"); + + SIPCommMenuBar smileyMenuBar = new SIPCommMenuBar(); + smileyMenuBar.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); + smileyMenuBar.add(smileysBox); + + this.add(smileyMenuBar); } /** @@ -522,6 +559,8 @@ else if (buttonText.equals("options")) { GuiActivator.getUIService().setConfigurationWindowVisible(true); } + else if (buttonText.equals("font")) + chatPanel.showFontChooserDialog(); } /** @@ -534,6 +573,11 @@ public ChatToolbarButton getHistoryButton() return historyButton; } + public SmileysSelectorBox getSmileysBox() + { + return smileysBox; + } + /** * Disables/Enables history arrow buttons depending on whether the * current page is the first, the last page or a middle page. @@ -584,6 +628,14 @@ private void setChatSession(ChatSession chatSession) } } + /** + * Adds a separator to this tool bar. + */ + private void addSeparator() + { + this.add(new JSeparator(SwingConstants.VERTICAL)); + } + /** * Reloads icons for buttons. */ @@ -598,6 +650,9 @@ public void loadSkin() sendFileButton.setIconImage(ImageLoader.getImage( ImageLoader.SEND_FILE_ICON)); + fontButton.setIconImage(ImageLoader.getImage( + ImageLoader.FONT_ICON)); + previousButton.setIconImage(ImageLoader.getImage( ImageLoader.PREVIOUS_ICON)); diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPane.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPane.java index 20833f197..ab499086b 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPane.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPane.java @@ -445,6 +445,9 @@ public void typingNotificationReceived(TypingNotificationEvent evt) int typingState = evt.getTypingState(); + ChatPanel chatPanel + = chatWindowManager.getContactChat(metaContact, false); + if (typingState == OperationSetTypingNotifications.STATE_TYPING) { notificationMsg @@ -452,39 +455,36 @@ public void typingNotificationReceived(TypingNotificationEvent evt) "service.gui.CONTACT_TYPING", new String[]{contactName}); - typingTimer.setMetaContact(metaContact); - typingTimer.start(); - // Proactive typing notification if (!chatWindowManager.isChatOpenedFor(metaContact)) { this.fireProactiveNotification(evt.getSourceContact()); return; } + + if (chatPanel != null) + chatPanel.addTypingNotification(notificationMsg); + + typingTimer.setMetaContact(metaContact); + typingTimer.start(); } else if (typingState == OperationSetTypingNotifications.STATE_PAUSED) { notificationMsg = GuiActivator.getResources().getI18NString( - "service.gui.CONTACT_PAUSED_TYPING", - new String[]{contactName}); + "service.gui.CONTACT_PAUSED_TYPING", + new String[]{contactName}); + + if (chatPanel != null) + chatPanel.addTypingNotification(notificationMsg); + typingTimer.setMetaContact(metaContact); typingTimer.start(); } - else if (typingState == OperationSetTypingNotifications.STATE_STOPPED) - { - notificationMsg = ""; - } - else if (typingState == OperationSetTypingNotifications.STATE_STALE) - { - notificationMsg - = GuiActivator.getResources().getI18NString( - "service.gui.CONTACT_TYPING_STATE_STALE"); - } - else if (typingState == OperationSetTypingNotifications.STATE_UNKNOWN) + else { - // TODO: Implement state unknown + if (chatPanel != null) + chatPanel.removeTypingNotification(); } - this.setChatNotificationMsg(metaContact, notificationMsg); } /** @@ -607,22 +607,6 @@ private void fireProactiveNotification(Contact contact) .getI18NString("service.gui.PROACTIVE_NOTIFICATION")); } - /** - * Sets the typing notification message at the appropriate chat. - * - * @param metaContact The meta contact. - * @param notificationMsg The typing notification message. - */ - public void setChatNotificationMsg(MetaContact metaContact, - String notificationMsg) - { - ChatPanel chatPanel - = chatWindowManager.getContactChat(metaContact, false); - - if (chatPanel != null) - chatPanel.setStatusMessage(notificationMsg); - } - /** * Returns the right button menu of the contact list. * @return the right button menu of the contact list @@ -653,7 +637,10 @@ private class TimerActionListener implements ActionListener { public void actionPerformed(ActionEvent e) { - setChatNotificationMsg(metaContact, ""); + ChatPanel chatPanel + = chatWindowManager.getContactChat(metaContact, false); + + chatPanel.removeTypingNotification(); } }